home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / src / out-of-phase-102-c / OutOfPhase 1.02 Source / OutOfPhase Folder / NoteObject.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-23  |  137.4 KB  |  3,718 lines  |  [TEXT/KAHL]

  1. /* NoteObject.c */
  2. /*****************************************************************************/
  3. /*                                                                           */
  4. /*    Out Of Phase:  Digital Music Synthesis on General Purpose Computers    */
  5. /*    Copyright (C) 1994  Thomas R. Lawrence                                 */
  6. /*                                                                           */
  7. /*    This program is free software; you can redistribute it and/or modify   */
  8. /*    it under the terms of the GNU General Public License as published by   */
  9. /*    the Free Software Foundation; either version 2 of the License, or      */
  10. /*    (at your option) any later version.                                    */
  11. /*                                                                           */
  12. /*    This program is distributed in the hope that it will be useful,        */
  13. /*    but WITHOUT ANY WARRANTY; without even the implied warranty of         */
  14. /*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          */
  15. /*    GNU General Public License for more details.                           */
  16. /*                                                                           */
  17. /*    You should have received a copy of the GNU General Public License      */
  18. /*    along with this program; if not, write to the Free Software            */
  19. /*    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.              */
  20. /*                                                                           */
  21. /*    Thomas R. Lawrence can be reached at tomlaw@world.std.com.             */
  22. /*                                                                           */
  23. /*****************************************************************************/
  24.  
  25. #include "MiscInfo.h"
  26. #include "Audit.h"
  27. #include "Debug.h"
  28. #include "Definitions.h"
  29.  
  30. #define ShowMe_NoteObjectRec
  31. #include "NoteObject.h"
  32. #include "Memory.h"
  33. #include "Fractions.h"
  34. #include "DrawCommand.h"
  35. #include "DataMunging.h"
  36. #include "Numbers.h"
  37. #include "Frequency.h"
  38. #include "BufferedFileInput.h"
  39. #include "BufferedFileOutput.h"
  40.  
  41.  
  42. /* create a new note with space for the specified number of parameters */
  43. NoteObjectRec*                NewNote(void)
  44.     {
  45.         NoteObjectRec*            Note;
  46.  
  47.         Note = (NoteObjectRec*)AllocPtrCanFail(sizeof(NoteObjectRec),"NoteObjectRec:Note");
  48.         if (Note == NIL)
  49.             {
  50.                 return NIL;
  51.             }
  52.         Note->Flags = /* duration unspecified*/ eRelease1FromDefault | eRelease2FromDefault
  53.             | ePitchDisplacementStartFromDefault | ePitchDisplacementDepthModeDefault
  54.             | eDetuningModeDefault | eDurationAdjustDefault;
  55.         Note->a.Note.Pitch = 0;
  56.         Note->a.Note.PortamentoDuration = 0;
  57.         Note->a.Note.EarlyLateAdjust = 0;
  58.         Note->a.Note.DurationAdjust = 0;
  59.         Note->a.Note.Tie = NIL;
  60.         Note->a.Note.ReleasePoint1 = 0;
  61.         Note->a.Note.ReleasePoint2 = 0;
  62.         Note->a.Note.OverallLoudnessAdjustment = Double2SmallBCD(1);
  63.         Note->a.Note.StereoPositionAdjustment = 0;
  64.         Note->a.Note.SurroundPositionAdjustment = 0;
  65.         Note->a.Note.Accent1 = 0;
  66.         Note->a.Note.Accent2 = 0;
  67.         Note->a.Note.Accent3 = 0;
  68.         Note->a.Note.Accent4 = 0;
  69.         Note->a.Note.MultisamplePitchAsIf = -1;
  70.         Note->a.Note.PitchDisplacementDepthAdjustment = Double2SmallBCD(1);
  71.         Note->a.Note.PitchDisplacementRateAdjustment = Double2SmallBCD(1);
  72.         Note->a.Note.PitchDisplacementStartPoint = 0;
  73.         Note->a.Note.HurryUpFactor = Double2SmallBCD(1);
  74.         Note->a.Note.Detuning = 0;
  75.         return Note;
  76.     }
  77.  
  78.  
  79. /* create a new command */
  80. NoteObjectRec*                NewCommand(void)
  81.     {
  82.         NoteObjectRec*            Note;
  83.  
  84.         Note = (NoteObjectRec*)AllocPtrCanFail(sizeof(NoteObjectRec),"NoteObjectRec:Command");
  85.         if (Note == NIL)
  86.             {
  87.              FailurePoint1:
  88.                 return NIL;
  89.             }
  90.         Note->a.Command.StringArgument = AllocPtrCanFail(0,"NoteObjectRec:Command:StringArg");
  91.         if (Note->a.Command.StringArgument == NIL)
  92.             {
  93.              FailurePoint2:
  94.                 ReleasePtr((char*)Note);
  95.                 goto FailurePoint1;
  96.             }
  97.         Note->a.Command.Argument1 = 0;
  98.         Note->a.Command.Argument2 = 0;
  99.         Note->a.Command.Argument3 = 0;
  100.         Note->Flags = eCommandFlag;
  101.         return Note;
  102.     }
  103.  
  104.  
  105. /* dispose of the note */
  106. void                                    DisposeNote(NoteObjectRec* Note)
  107.     {
  108.         CheckPtrExistence(Note);
  109.         if (IsItACommand(Note))
  110.             {
  111.                 ReleasePtr(Note->a.Command.StringArgument);
  112.             }
  113.         ReleasePtr((char*)Note);
  114.     }
  115.  
  116.  
  117. /* find out what type of thing it is */
  118. MyBoolean                            IsItACommand(NoteObjectRec* Note)
  119.     {
  120.         CheckPtrExistence(Note);
  121.         return ((Note->Flags & eCommandFlag) != 0);
  122.     }
  123.  
  124.  
  125. /* convert the duration of the note into a fraction.  the numbers are not reduced */
  126. /* with the aim of eliminating as much factoring as possible to reduce the number */
  127. /* of lengthy multiplies and divides. */
  128. void                                    GetNoteDurationFrac(NoteObjectRec* Note, struct FractionRec* Frac)
  129.     {
  130.         unsigned long                Temp;
  131.  
  132.         CheckPtrExistence(Note);
  133.         ERROR(IsItACommand(Note),PRERR(ForceAbort,"GetNoteDurationFrac called on command"));
  134.         /* the denominator factors represent the following: */
  135.         /* 64 for 1/64th note, 3*5*7 for divided notes, and 2 for 3/2 dotted notes */
  136.         Frac->Denominator = (64*3*5*7*2);
  137.         switch (Note->Flags & eDurationMask)
  138.             {
  139.                 default:
  140.                     EXECUTE(PRERR(ForceAbort,"GetNoteDurationFrac:  bad duration value"));
  141.                     break;
  142.                 case e64thNote:
  143.                     Frac->Integer = 0;
  144.                     Frac->Fraction = 1 * (64*3*5*7*2) / 64;
  145.                     break;
  146.                 case e32ndNote:
  147.                     Frac->Integer = 0;
  148.                     Frac->Fraction = 1 * (64*3*5*7*2) / 32;
  149.                     break;
  150.                 case e16thNote:
  151.                     Frac->Integer = 0;
  152.                     Frac->Fraction = 1 * (64*3*5*7*2) / 16;
  153.                     break;
  154.                 case e8thNote:
  155.                     Frac->Integer = 0;
  156.                     Frac->Fraction = 1 * (64*3*5*7*2) / 8;
  157.                     break;
  158.                 case e4thNote:
  159.                     Frac->Integer = 0;
  160.                     Frac->Fraction = 1 * (64*3*5*7*2) / 4;
  161.                     break;
  162.                 case e2ndNote:
  163.                     Frac->Integer = 0;
  164.                     Frac->Fraction = 1 * (64*3*5*7*2) / 2;
  165.                     break;
  166.                 case eWholeNote:
  167.                     Frac->Integer = 1;
  168.                     Frac->Fraction = 0;
  169.                     break;
  170.                 case eDoubleNote:
  171.                     Frac->Integer = 2;
  172.                     Frac->Fraction = 0;
  173.                     break;
  174.                 case eQuadNote:
  175.                     Frac->Integer = 4;
  176.                     Frac->Fraction = 0;
  177.                     break;
  178.             }
  179.         if ((Note->Flags & eDotModifier) != 0)
  180.             {
  181.                 /* since the denominator is (64*3*5*7*2), with a 2 in it, we only have */
  182.                 /* to multiply note by 3/2 */
  183.                 Temp = (3 * (Frac->Fraction + Frac->Integer * (64*3*5*7*2))) / 2;
  184.                 Frac->Integer = Temp / (64*3*5*7*2);
  185.                 Frac->Fraction = Temp % (64*3*5*7*2);
  186.             }
  187.         switch (Note->Flags & eDivisionMask)
  188.             {
  189.                 default:
  190.                     EXECUTE(PRERR(ForceAbort,"GetNoteDurationFrac:  bad division"));
  191.                     break;
  192.                 case eDiv1Modifier:
  193.                     break;
  194.                 case eDiv3Modifier:
  195.                     /* since the denominator is (64*3*5*7*2), with a 3 in it, we only have */
  196.                     /* to multiply note by 1/3 */
  197.                     Temp = (Frac->Fraction + Frac->Integer * (64*3*5*7*2)) / 3;
  198.                     Frac->Integer = Temp / (64*3*5*7*2);
  199.                     Frac->Fraction = Temp % (64*3*5*7*2);
  200.                     break;
  201.                 case eDiv5Modifier:
  202.                     /* since the denominator is (64*3*5*7*2), with a 5 in it, we only have */
  203.                     /* to multiply note by 1/5 */
  204.                     Temp = (Frac->Fraction + Frac->Integer * (64*3*5*7*2)) / 5;
  205.                     Frac->Integer = Temp / (64*3*5*7*2);
  206.                     Frac->Fraction = Temp % (64*3*5*7*2);
  207.                     break;
  208.                 case eDiv7Modifier:
  209.                     /* since the denominator is (64*3*5*7*2), with a 7 in it, we only have */
  210.                     /* to multiply note by 1/7 */
  211.                     Temp = (Frac->Fraction + Frac->Integer * (64*3*5*7*2)) / 7;
  212.                     Frac->Integer = Temp / (64*3*5*7*2);
  213.                     Frac->Fraction = Temp % (64*3*5*7*2);
  214.                     break;
  215.             }
  216.     }
  217.  
  218.  
  219. /* draw the command on the screen, or measure how many pixels wide the image will be */
  220. /* if it will draw, it assumes the clipping rectangle to be set up properly */
  221. OrdType                                DrawCommandOnScreen(WinType* Window, OrdType X, OrdType Y,
  222.                                                 FontType Font, FontSizeType FontSize, OrdType FontHeight,
  223.                                                 NoteObjectRec* Note, MyBoolean ActuallyDraw, MyBoolean GreyedOut)
  224.     {
  225.         char*                                Name;
  226.         CommandAddrMode            Params;
  227.         OrdType                            ReturnValue;
  228.  
  229.         CheckPtrExistence(Note);
  230.         ERROR(!IsItACommand(Note),PRERR(ForceAbort,"DrawCommandOnScreen:  not a command"));
  231.         /* find out what the command's name is */
  232.         Name = GetCommandName((NoteCommands)(Note->Flags & ~eCommandFlag));
  233.         /* figure out what needs to be drawn for the command */
  234.         Params = GetCommandAddressingMode((NoteCommands)(Note->Flags & ~eCommandFlag));
  235.         /* perform the actual drawing of the command */
  236.         switch (Params)
  237.             {
  238.                 default:
  239.                     EXECUTE(PRERR(ForceAbort,"DrawCommandOnScreen:  bad command addressing mode"));
  240.                     break;
  241.                 case eNoParameters:
  242.                     ReturnValue = DrawCommandNoParams(Window,X,Y,Font,FontSize,ActuallyDraw,
  243.                         GreyedOut,Name);
  244.                     break;
  245.                 case e1SmallExtParameter: /* <1xs> */
  246.                     ReturnValue = DrawCommand1Param(Window,X,Y,Font,FontSize,ActuallyDraw,
  247.                         GreyedOut,Name,SmallExtBCDToString(Note->a.Command.Argument1));
  248.                     break;
  249.                 case e2SmallExtParameters: /* <1xs> <2xs> */
  250.                     ReturnValue = DrawCommand2Params(Window,X,Y,Font,FontSize,ActuallyDraw,
  251.                         GreyedOut,Name,SmallExtBCDToString(Note->a.Command.Argument1),
  252.                         SmallExtBCDToString(Note->a.Command.Argument2));
  253.                     break;
  254.                 case e1LargeParameter: /* <1l> */
  255.                     ReturnValue = DrawCommand1Param(Window,X,Y,Font,FontSize,ActuallyDraw,
  256.                         GreyedOut,Name,LargeBCDToString(Note->a.Command.Argument1));
  257.                     break;
  258.                 case eFirstLargeSecondSmallExtParameters: /* <1l> <2xs> */
  259.                     ReturnValue = DrawCommand2Params(Window,X,Y,Font,FontSize,ActuallyDraw,
  260.                         GreyedOut,Name,LargeBCDToString(Note->a.Command.Argument1),
  261.                         SmallExtBCDToString(Note->a.Command.Argument2));
  262.                     break;
  263.                 case e1ParamReleaseOrigin: /* origin <1i> */
  264.                     ERROR((Note->a.Command.Argument1 != 0) && (Note->a.Command.Argument1 != -1),
  265.                         PRERR(ForceAbort,"DrawCommandOnScreen:  bad value in argument 1"));
  266.                     ReturnValue = DrawCommand1Param(Window,X,Y,Font,FontSize,ActuallyDraw,
  267.                         GreyedOut,Name,StringToBlockCopy((Note->a.Command.Argument1 >= 0)
  268.                         ? "From End" : "From Start"));
  269.                     break;
  270.                 case e1PitchDisplacementMode: /* hertz/steps <1i> */
  271.                     ERROR((Note->a.Command.Argument1 != 0) && (Note->a.Command.Argument1 != -1),
  272.                         PRERR(ForceAbort,"DrawCommandOnScreen:  bad value in argument 1"));
  273.                     ReturnValue = DrawCommand1Param(Window,X,Y,Font,FontSize,ActuallyDraw,
  274.                         GreyedOut,Name,StringToBlockCopy((Note->a.Command.Argument1 >= 0)
  275.                         ? "Half-Steps" : "Hertz"));
  276.                     break;
  277.                 case e2IntegerParameters: /* <1i> <2i> */
  278.                     ReturnValue = DrawCommand2Params(Window,X,Y,Font,FontSize,ActuallyDraw,
  279.                         GreyedOut,Name,IntegerToString(Note->a.Command.Argument1),
  280.                         IntegerToString(Note->a.Command.Argument2));
  281.                     break;
  282.                 case e1DurationAdjustMode: /* multiplicative/additive <1i> */
  283.                     ERROR((Note->a.Command.Argument1 != 0) && (Note->a.Command.Argument1 != -1),
  284.                         PRERR(ForceAbort,"DrawCommandOnScreen:  bad value in argument 1"));
  285.                     ReturnValue = DrawCommand1Param(Window,X,Y,Font,FontSize,ActuallyDraw,
  286.                         GreyedOut,Name,StringToBlockCopy((Note->a.Command.Argument1 >= 0)
  287.                         ? "Additive" : "Multiplicative"));
  288.                     break;
  289.                 case e1IntegerParameter: /* <1i> */
  290.                     ReturnValue = DrawCommand1Param(Window,X,Y,Font,FontSize,ActuallyDraw,
  291.                         GreyedOut,Name,IntegerToString(Note->a.Command.Argument1));
  292.                     break;
  293.                 case e1StringParameterWithLineFeeds: /* <string> */
  294.                     ReturnValue = DrawCommand1ParamWithLineFeeds(Window,X,Y,Font,FontSize,
  295.                         ActuallyDraw,GreyedOut,Name,CopyPtr(Note->a.Command.StringArgument));
  296.                     break;
  297.             }
  298.         /* report width of thing to caller */
  299.         return ReturnValue;
  300.     }
  301.  
  302.  
  303. /* get a static null terminated string literal containing the name of a command */
  304. char*                                    GetCommandName(NoteCommands Command)
  305.     {
  306.         char*                                Name;
  307.  
  308.         switch (Command)
  309.             {
  310.                 default:
  311.                     EXECUTE(PRERR(ForceAbort,"GetCommandName:  unknown command opcode"));
  312.                     break;
  313.                 case eCmdRestoreTempo:
  314.                     Name = "Restore Tempo";
  315.                     break;
  316.                 case eCmdSetTempo:
  317.                     Name = "Set Tempo";
  318.                     break;
  319.                 case eCmdIncTempo:
  320.                     Name = "Adjust Tempo";
  321.                     break;
  322.                 case eCmdSweepTempoAbs:
  323.                     Name = "Sweep Tempo Absolute";
  324.                     break;
  325.                 case eCmdSweepTempoRel:
  326.                     Name = "Sweep Tempo Relative";
  327.                     break;
  328.                 case eCmdRestoreStereoPosition:
  329.                     Name = "Restore Stereo Position";
  330.                     break;
  331.                 case eCmdSetStereoPosition:
  332.                     Name = "Set Stereo Position";
  333.                     break;
  334.                 case eCmdIncStereoPosition:
  335.                     Name = "Adjust Stereo Position";
  336.                     break;
  337.                 case eCmdSweepStereoAbs:
  338.                     Name = "Sweep Stereo Position Absolute";
  339.                     break;
  340.                 case eCmdSweepStereoRel:
  341.                     Name = "Sweep Stereo Position Relative";
  342.                     break;
  343.                 case eCmdRestoreVolume:
  344.                     Name = "Restore Volume";
  345.                     break;
  346.                 case eCmdRestoreSurroundPosition:
  347.                     Name = "Restore Surround Position";
  348.                     break;
  349.                 case eCmdSetSurroundPosition:
  350.                     Name = "Set Surround Position";
  351.                     break;
  352.                 case eCmdIncSurroundPosition:
  353.                     Name = "Adjust Surround Position";
  354.                     break;
  355.                 case eCmdSweepSurroundAbs:
  356.                     Name = "Sweep Surround Position Absolute";
  357.                     break;
  358.                 case eCmdSweepSurroundRel:
  359.                     Name = "Sweep Surround Position Relative";
  360.                     break;
  361.                 case eCmdSetVolume:
  362.                     Name = "Set Volume";
  363.                     break;
  364.                 case eCmdIncVolume:
  365.                     Name = "Adjust Volume";
  366.                     break;
  367.                 case eCmdSweepVolumeAbs:
  368.                     Name = "Sweep Volume Absolute";
  369.                     break;
  370.                 case eCmdSweepVolumeRel:
  371.                     Name = "Sweep Volume Relative";
  372.                     break;
  373.                 case eCmdRestoreReleasePoint1:
  374.                     Name = "Restore Release Point 1";
  375.                     break;
  376.                 case eCmdSetReleasePoint1:
  377.                     Name = "Set Release Point 1";
  378.                     break;
  379.                 case eCmdIncReleasePoint1:
  380.                     Name = "Adjust Release Point 1";
  381.                     break;
  382.                 case eCmdReleasePointOrigin1:
  383.                     Name = "Set Release Point 1 Origin";
  384.                     break;
  385.                 case eCmdSweepReleaseAbs1:
  386.                     Name = "Sweep Release Point 1 Absolute";
  387.                     break;
  388.                 case eCmdSweepReleaseRel1:
  389.                     Name = "Sweep Release Point 1 Relative";
  390.                     break;
  391.                 case eCmdRestoreReleasePoint2:
  392.                     Name = "Restore Release Point 2";
  393.                     break;
  394.                 case eCmdSetReleasePoint2:
  395.                     Name = "Set Release Point 2";
  396.                     break;
  397.                 case eCmdIncReleasePoint2:
  398.                     Name = "Adjust Release Point 2";
  399.                     break;
  400.                 case eCmdReleasePointOrigin2:
  401.                     Name = "Set Release Point 2 Origin";
  402.                     break;
  403.                 case eCmdSweepReleaseAbs2:
  404.                     Name = "Sweep Release Point 2 Absolute";
  405.                     break;
  406.                 case eCmdSweepReleaseRel2:
  407.                     Name = "Sweep Release Point 2 Relative";
  408.                     break;
  409.                 case eCmdRestoreAccent1:
  410.                     Name = "Restore Accent 1";
  411.                     break;
  412.                 case eCmdSetAccent1:
  413.                     Name = "Set Accent 1";
  414.                     break;
  415.                 case eCmdIncAccent1:
  416.                     Name = "Adjust Accent 1";
  417.                     break;
  418.                 case eCmdSweepAccentAbs1:
  419.                     Name = "Sweep Accent 1 Absolute";
  420.                     break;
  421.                 case eCmdSweepAccentRel1:
  422.                     Name = "Sweep Accent 1 Relative";
  423.                     break;
  424.                 case eCmdRestoreAccent2:
  425.                     Name = "Restore Accent 2";
  426.                     break;
  427.                 case eCmdSetAccent2:
  428.                     Name = "Set Accent 2";
  429.                     break;
  430.                 case eCmdIncAccent2:
  431.                     Name = "Adjust Accent 2";
  432.                     break;
  433.                 case eCmdSweepAccentAbs2:
  434.                     Name = "Sweep Accent 2 Absolute";
  435.                     break;
  436.                 case eCmdSweepAccentRel2:
  437.                     Name = "Sweep Accent 2 Relative";
  438.                     break;
  439.                 case eCmdRestoreAccent3:
  440.                     Name = "Restore Accent 3";
  441.                     break;
  442.                 case eCmdSetAccent3:
  443.                     Name = "Set Accent 3";
  444.                     break;
  445.                 case eCmdIncAccent3:
  446.                     Name = "Adjust Accent 3";
  447.                     break;
  448.                 case eCmdSweepAccentAbs3:
  449.                     Name = "Sweep Accent 3 Absolute";
  450.                     break;
  451.                 case eCmdSweepAccentRel3:
  452.                     Name = "Sweep Accent 3 Relative";
  453.                     break;
  454.                 case eCmdRestoreAccent4:
  455.                     Name = "Restore Accent 4";
  456.                     break;
  457.                 case eCmdSetAccent4:
  458.                     Name = "Set Accent 4";
  459.                     break;
  460.                 case eCmdIncAccent4:
  461.                     Name = "Adjust Accent 4";
  462.                     break;
  463.                 case eCmdSweepAccentAbs4:
  464.                     Name = "Sweep Accent 4 Absolute";
  465.                     break;
  466.                 case eCmdSweepAccentRel4:
  467.                     Name = "Sweep Accent 4 Relative";
  468.                     break;
  469.                 case eCmdRestorePitchDispDepth:
  470.                     Name = "Restore Pitch Displacement Depth";
  471.                     break;
  472.                 case eCmdSetPitchDispDepth:
  473.                     Name = "Set Pitch Displacement Depth";
  474.                     break;
  475.                 case eCmdIncPitchDispDepth:
  476.                     Name = "Adjust Pitch Displacement Depth";
  477.                     break;
  478.                 case eCmdPitchDispDepthMode:
  479.                     Name = "Set Pitch Displacement Mode";
  480.                     break;
  481.                 case eCmdSweepPitchDispDepthAbs:
  482.                     Name = "Sweep Pitch Displacement Depth Absolute";
  483.                     break;
  484.                 case eCmdSweepPitchDispDepthRel:
  485.                     Name = "Sweep Pitch Displacement Depth Relative";
  486.                     break;
  487.                 case eCmdRestorePitchDispRate:
  488.                     Name = "Restore Pitch Displacement Rate";
  489.                     break;
  490.                 case eCmdSetPitchDispRate:
  491.                     Name = "Set Pitch Displacement Rate";
  492.                     break;
  493.                 case eCmdIncPitchDispRate:
  494.                     Name = "Adjust Pitch Displacement Rate";
  495.                     break;
  496.                 case eCmdSweepPitchDispRateAbs:
  497.                     Name = "Sweep Pitch Displacement Rate Absolute";
  498.                     break;
  499.                 case eCmdSweepPitchDispRateRel:
  500.                     Name = "Sweep Pitch Displacement Rate Relative";
  501.                     break;
  502.                 case eCmdRestorePitchDispStart:
  503.                     Name = "Restore Pitch Displacement Start Point";
  504.                     break;
  505.                 case eCmdSetPitchDispStart:
  506.                     Name = "Set Pitch Displacement Start Point";
  507.                     break;
  508.                 case eCmdIncPitchDispStart:
  509.                     Name = "Adjust Pitch Displacement Start Point";
  510.                     break;
  511.                 case eCmdPitchDispStartOrigin:
  512.                     Name = "Set Pitch Displacement Start Point Origin";
  513.                     break;
  514.                 case eCmdSweepPitchDispStartAbs:
  515.                     Name = "Sweep Pitch Displacement Start Point Absolute";
  516.                     break;
  517.                 case eCmdSweepPitchDispStartRel:
  518.                     Name = "Sweep Pitch Displacement Start Point Relative";
  519.                     break;
  520.                 case eCmdRestoreHurryUp:
  521.                     Name = "Restore Hurry-Up";
  522.                     break;
  523.                 case eCmdSetHurryUp:
  524.                     Name = "Set Hurry-Up";
  525.                     break;
  526.                 case eCmdIncHurryUp:
  527.                     Name = "Adjust Hurry-Up";
  528.                     break;
  529.                 case eCmdSweepHurryUpAbs:
  530.                     Name = "Sweep Hurry-Up Absolute";
  531.                     break;
  532.                 case eCmdSweepHurryUpRel:
  533.                     Name = "Sweep Hurry-Up Relative";
  534.                     break;
  535.                 case eCmdRestoreDetune:
  536.                     Name = "Restore Detuning";
  537.                     break;
  538.                 case eCmdSetDetune:
  539.                     Name = "Set Detuning";
  540.                     break;
  541.                 case eCmdIncDetune:
  542.                     Name = "Adjust Detuning";
  543.                     break;
  544.                 case eCmdDetuneMode:
  545.                     Name = "Set Detuning Mode";
  546.                     break;
  547.                 case eCmdSweepDetuneAbs:
  548.                     Name = "Sweep Detuning Absolute";
  549.                     break;
  550.                 case eCmdSweepDetuneRel:
  551.                     Name = "Sweep Detuning Relative";
  552.                     break;
  553.                 case eCmdRestoreEarlyLateAdjust:
  554.                     Name = "Restore Hit Time";
  555.                     break;
  556.                 case eCmdSetEarlyLateAdjust:
  557.                     Name = "Set Hit Time";
  558.                     break;
  559.                 case eCmdIncEarlyLateAdjust:
  560.                     Name = "Adjust Hit Time";
  561.                     break;
  562.                 case eCmdSweepEarlyLateAbs:
  563.                     Name = "Sweep Hit Time Absolute";
  564.                     break;
  565.                 case eCmdSweepEarlyLateRel:
  566.                     Name = "Sweep Hit Time Relative";
  567.                     break;
  568.                 case eCmdRestoreDurationAdjust:
  569.                     Name = "Restore Duration";
  570.                     break;
  571.                 case eCmdSetDurationAdjust:
  572.                     Name = "Set Duration";
  573.                     break;
  574.                 case eCmdIncDurationAdjust:
  575.                     Name = "Adjust Duration";
  576.                     break;
  577.                 case eCmdSweepDurationAbs:
  578.                     Name = "Sweep Duration Absolute";
  579.                     break;
  580.                 case eCmdSweepDurationRel:
  581.                     Name = "Sweep Duration Relative";
  582.                     break;
  583.                 case eCmdDurationAdjustMode:
  584.                     Name = "Set Duration Mode";
  585.                     break;
  586.                 case eCmdSetMeter:
  587.                     Name = "Set Meter";
  588.                     break;
  589.                 case eCmdSetMeasureNumber:
  590.                     Name = "Set Measure Number";
  591.                     break;
  592.                 case eCmdSetTranspose:
  593.                     Name = "Set Transpose";
  594.                     break;
  595.                 case eCmdAdjustTranspose:
  596.                     Name = "Adjust Transpose";
  597.                     break;
  598.                 case eCmdMarker:
  599.                     Name = "Marker";
  600.                     break;
  601.             }
  602.         return Name;
  603.     }
  604.  
  605.  
  606. /* get the addressing mode for a command */
  607. CommandAddrMode                GetCommandAddressingMode(NoteCommands Command)
  608.     {
  609.         CommandAddrMode            Params;
  610.  
  611.         switch (Command)
  612.             {
  613.                 default:
  614.                     EXECUTE(PRERR(ForceAbort,"GetCommandAddressingMode:  unknown command opcode"));
  615.                     break;
  616.                 case eCmdRestoreTempo: /* no parameters */
  617.                     Params = eNoParameters;
  618.                     break;
  619.                 case eCmdSetTempo: /* <1xs> */
  620.                     Params = e1SmallExtParameter;
  621.                     break;
  622.                 case eCmdIncTempo: /* <1xs> */
  623.                     Params = e1SmallExtParameter;
  624.                     break;
  625.                 case eCmdSweepTempoAbs: /* <1xs> <2xs> */
  626.                     Params = e2SmallExtParameters;
  627.                     break;
  628.                 case eCmdSweepTempoRel: /* <1xs> <2xs> */
  629.                     Params = e2SmallExtParameters;
  630.                     break;
  631.                 case eCmdRestoreStereoPosition: /* no parameters */
  632.                     Params = eNoParameters;
  633.                     break;
  634.                 case eCmdSetStereoPosition: /* <1l> */
  635.                     Params = e1LargeParameter;
  636.                     break;
  637.                 case eCmdIncStereoPosition: /* <1l> */
  638.                     Params = e1LargeParameter;
  639.                     break;
  640.                 case eCmdSweepStereoAbs: /* <1l> <2xs> */
  641.                     Params = eFirstLargeSecondSmallExtParameters;
  642.                     break;
  643.                 case eCmdSweepStereoRel: /* <1l> <2xs> */
  644.                     Params = eFirstLargeSecondSmallExtParameters;
  645.                     break;
  646.                 case eCmdRestoreSurroundPosition: /* no parameters */
  647.                     Params = eNoParameters;
  648.                     break;
  649.                 case eCmdSetSurroundPosition: /* <1l> */
  650.                     Params = e1LargeParameter;
  651.                     break;
  652.                 case eCmdIncSurroundPosition: /* <1l> */
  653.                     Params = e1LargeParameter;
  654.                     break;
  655.                 case eCmdSweepSurroundAbs: /* <1l> <2xs> */
  656.                     Params = eFirstLargeSecondSmallExtParameters;
  657.                     break;
  658.                 case eCmdSweepSurroundRel: /* <1l> <2xs> */
  659.                     Params = eFirstLargeSecondSmallExtParameters;
  660.                     break;
  661.                 case eCmdRestoreVolume: /* no parameters */
  662.                     Params = eNoParameters;
  663.                     break;
  664.                 case eCmdSetVolume: /* <1l> */
  665.                     Params = e1LargeParameter;
  666.                     break;
  667.                 case eCmdIncVolume: /* <1l> */
  668.                     Params = e1LargeParameter;
  669.                     break;
  670.                 case eCmdSweepVolumeAbs: /* <1l> <2xs> */
  671.                     Params = eFirstLargeSecondSmallExtParameters;
  672.                     break;
  673.                 case eCmdSweepVolumeRel: /* <1l> <2xs> */
  674.                     Params = eFirstLargeSecondSmallExtParameters;
  675.                     break;
  676.                 case eCmdRestoreReleasePoint1: /* no parameters */
  677.                     Params = eNoParameters;
  678.                     break;
  679.                 case eCmdSetReleasePoint1: /* <1l> */
  680.                     Params = e1LargeParameter;
  681.                     break;
  682.                 case eCmdIncReleasePoint1: /* <1l> */
  683.                     Params = e1LargeParameter;
  684.                     break;
  685.                 case eCmdReleasePointOrigin1: /* origin <1i> */
  686.                     Params = e1ParamReleaseOrigin;
  687.                     break;
  688.                 case eCmdSweepReleaseAbs1: /* <1l> <2xs> */
  689.                     Params = eFirstLargeSecondSmallExtParameters;
  690.                     break;
  691.                 case eCmdSweepReleaseRel1: /* <1l> <2xs> */
  692.                     Params = eFirstLargeSecondSmallExtParameters;
  693.                     break;
  694.                 case eCmdRestoreReleasePoint2: /* no parameters */
  695.                     Params = eNoParameters;
  696.                     break;
  697.                 case eCmdSetReleasePoint2: /* <1l> */
  698.                     Params = e1LargeParameter;
  699.                     break;
  700.                 case eCmdIncReleasePoint2: /* <1l> */
  701.                     Params = e1LargeParameter;
  702.                     break;
  703.                 case eCmdReleasePointOrigin2: /* origin <1i> */
  704.                     Params = e1ParamReleaseOrigin;
  705.                     break;
  706.                 case eCmdSweepReleaseAbs2: /* <1l> <2xs> */
  707.                     Params = eFirstLargeSecondSmallExtParameters;
  708.                     break;
  709.                 case eCmdSweepReleaseRel2: /* <1l> <2xs> */
  710.                     Params = eFirstLargeSecondSmallExtParameters;
  711.                     break;
  712.                 case eCmdRestoreAccent1: /* no parameters */
  713.                     Params = eNoParameters;
  714.                     break;
  715.                 case eCmdSetAccent1: /* <1l> */
  716.                     Params = e1LargeParameter;
  717.                     break;
  718.                 case eCmdIncAccent1: /* <1l> */
  719.                     Params = e1LargeParameter;
  720.                     break;
  721.                 case eCmdSweepAccentAbs1: /* <1l> <2xs> */
  722.                     Params = eFirstLargeSecondSmallExtParameters;
  723.                     break;
  724.                 case eCmdSweepAccentRel1: /* <1l> <2xs> */
  725.                     Params = eFirstLargeSecondSmallExtParameters;
  726.                     break;
  727.                 case eCmdRestoreAccent2: /* no parameters */
  728.                     Params = eNoParameters;
  729.                     break;
  730.                 case eCmdSetAccent2: /* <1l> */
  731.                     Params = e1LargeParameter;
  732.                     break;
  733.                 case eCmdIncAccent2: /* <1l> */
  734.                     Params = e1LargeParameter;
  735.                     break;
  736.                 case eCmdSweepAccentAbs2: /* <1l> <2xs> */
  737.                     Params = eFirstLargeSecondSmallExtParameters;
  738.                     break;
  739.                 case eCmdSweepAccentRel2: /* <1l> <2xs> */
  740.                     Params = eFirstLargeSecondSmallExtParameters;
  741.                     break;
  742.                 case eCmdRestoreAccent3: /* no parameters */
  743.                     Params = eNoParameters;
  744.                     break;
  745.                 case eCmdSetAccent3: /* <1l> */
  746.                     Params = e1LargeParameter;
  747.                     break;
  748.                 case eCmdIncAccent3: /* <1l> */
  749.                     Params = e1LargeParameter;
  750.                     break;
  751.                 case eCmdSweepAccentAbs3: /* <1l> <2xs> */
  752.                     Params = eFirstLargeSecondSmallExtParameters;
  753.                     break;
  754.                 case eCmdSweepAccentRel3: /* <1l> <2xs> */
  755.                     Params = eFirstLargeSecondSmallExtParameters;
  756.                     break;
  757.                 case eCmdRestoreAccent4: /* no parameters */
  758.                     Params = eNoParameters;
  759.                     break;
  760.                 case eCmdSetAccent4: /* <1l> */
  761.                     Params = e1LargeParameter;
  762.                     break;
  763.                 case eCmdIncAccent4: /* <1l> */
  764.                     Params = eFirstLargeSecondSmallExtParameters;
  765.                     break;
  766.                 case eCmdSweepAccentAbs4: /* <1l> <2xs> */
  767.                     Params = eFirstLargeSecondSmallExtParameters;
  768.                     break;
  769.                 case eCmdSweepAccentRel4: /* <1l> <2xs> */
  770.                     Params = eFirstLargeSecondSmallExtParameters;
  771.                     break;
  772.                 case eCmdRestorePitchDispDepth: /* no parameters */
  773.                     Params = eNoParameters;
  774.                     break;
  775.                 case eCmdSetPitchDispDepth: /* <1l> */
  776.                     Params = e1LargeParameter;
  777.                     break;
  778.                 case eCmdIncPitchDispDepth: /* <1l> */
  779.                     Params = e1LargeParameter;
  780.                     break;
  781.                 case eCmdPitchDispDepthMode: /* hertz/steps <1i> */
  782.                     Params = e1PitchDisplacementMode;
  783.                     break;
  784.                 case eCmdSweepPitchDispDepthAbs: /* <1l> <2xs> */
  785.                     Params = eFirstLargeSecondSmallExtParameters;
  786.                     break;
  787.                 case eCmdSweepPitchDispDepthRel: /* <1l> <2xs> */
  788.                     Params = eFirstLargeSecondSmallExtParameters;
  789.                     break;
  790.                 case eCmdRestorePitchDispRate: /* no parameters */
  791.                     Params = eNoParameters;
  792.                     break;
  793.                 case eCmdSetPitchDispRate: /* <1l> */
  794.                     Params = e1LargeParameter;
  795.                     break;
  796.                 case eCmdIncPitchDispRate: /* <1l> */
  797.                     Params = e1LargeParameter;
  798.                     break;
  799.                 case eCmdSweepPitchDispRateAbs: /* <1l> <2xs> */
  800.                     Params = eFirstLargeSecondSmallExtParameters;
  801.                     break;
  802.                 case eCmdSweepPitchDispRateRel: /* <1l> <2xs> */
  803.                     Params = eFirstLargeSecondSmallExtParameters;
  804.                     break;
  805.                 case eCmdRestorePitchDispStart: /* no parameters */
  806.                     Params = eNoParameters;
  807.                     break;
  808.                 case eCmdSetPitchDispStart: /* <1l> */
  809.                     Params = e1LargeParameter;
  810.                     break;
  811.                 case eCmdIncPitchDispStart: /* <1l> */
  812.                     Params = e1LargeParameter;
  813.                     break;
  814.                 case eCmdPitchDispStartOrigin: /* origin <1i> */
  815.                     Params = e1ParamReleaseOrigin;
  816.                     break;
  817.                 case eCmdSweepPitchDispStartAbs: /* <1l> <2xs> */
  818.                     Params = eFirstLargeSecondSmallExtParameters;
  819.                     break;
  820.                 case eCmdSweepPitchDispStartRel: /* <1l> <2xs> */
  821.                     Params = eFirstLargeSecondSmallExtParameters;
  822.                     break;
  823.                 case eCmdRestoreHurryUp: /* no parameters */
  824.                     Params = eNoParameters;
  825.                     break;
  826.                 case eCmdSetHurryUp: /* <1l> */
  827.                     Params = e1LargeParameter;
  828.                     break;
  829.                 case eCmdIncHurryUp: /* <1l> */
  830.                     Params = e1LargeParameter;
  831.                     break;
  832.                 case eCmdSweepHurryUpAbs: /* <1l> <2xs> */
  833.                     Params = eFirstLargeSecondSmallExtParameters;
  834.                     break;
  835.                 case eCmdSweepHurryUpRel: /* <1l> <2xs> */
  836.                     Params = eFirstLargeSecondSmallExtParameters;
  837.                     break;
  838.                 case eCmdRestoreDetune: /* no parameters */
  839.                     Params = eNoParameters;
  840.                     break;
  841.                 case eCmdSetDetune: /* <1l> */
  842.                     Params = e1LargeParameter;
  843.                     break;
  844.                 case eCmdIncDetune: /* <1l> */
  845.                     Params = e1LargeParameter;
  846.                     break;
  847.                 case eCmdDetuneMode: /* hertz/steps <1i> */
  848.                     Params = e1PitchDisplacementMode;
  849.                     break;
  850.                 case eCmdSweepDetuneAbs: /* <1l> <2xs> */
  851.                     Params = eFirstLargeSecondSmallExtParameters;
  852.                     break;
  853.                 case eCmdSweepDetuneRel: /* <1l> <2xs> */
  854.                     Params = eFirstLargeSecondSmallExtParameters;
  855.                     break;
  856.                 case eCmdRestoreEarlyLateAdjust: /* no parameters */
  857.                     Params = eNoParameters;
  858.                     break;
  859.                 case eCmdSetEarlyLateAdjust: /* <1l> */
  860.                     Params = e1LargeParameter;
  861.                     break;
  862.                 case eCmdIncEarlyLateAdjust: /* <1l> */
  863.                     Params = e1LargeParameter;
  864.                     break;
  865.                 case eCmdSweepEarlyLateAbs: /* <1l> <2xs> */
  866.                     Params = eFirstLargeSecondSmallExtParameters;
  867.                     break;
  868.                 case eCmdSweepEarlyLateRel: /* <1l> <2xs> */
  869.                     Params = eFirstLargeSecondSmallExtParameters;
  870.                     break;
  871.                 case eCmdRestoreDurationAdjust: /* no parameters */
  872.                     Params = eNoParameters;
  873.                     break;
  874.                 case eCmdSetDurationAdjust: /* <1l> */
  875.                     Params = e1LargeParameter;
  876.                     break;
  877.                 case eCmdIncDurationAdjust: /* <1l> */
  878.                     Params = e1LargeParameter;
  879.                     break;
  880.                 case eCmdSweepDurationAbs: /* <1l> <2xs> */
  881.                     Params = eFirstLargeSecondSmallExtParameters;
  882.                     break;
  883.                 case eCmdSweepDurationRel: /* <1l> <2xs> */
  884.                     Params = eFirstLargeSecondSmallExtParameters;
  885.                     break;
  886.                 case eCmdDurationAdjustMode: /* multiplicative/additive <1i> */
  887.                     Params = e1DurationAdjustMode;
  888.                     break;
  889.                 case eCmdSetMeter: /* <1i> <2i> */
  890.                     Params = e2IntegerParameters;
  891.                     break;
  892.                 case eCmdSetMeasureNumber: /* <1i> */
  893.                     Params = e1IntegerParameter;
  894.                     break;
  895.                 case eCmdSetTranspose: /* <1i> */
  896.                     Params = e1IntegerParameter;
  897.                     break;
  898.                 case eCmdAdjustTranspose: /* <1i> */
  899.                     Params = e1IntegerParameter;
  900.                     break;
  901.                 case eCmdMarker: /* <string> */
  902.                     Params = e1StringParameterWithLineFeeds;
  903.                     break;
  904.             }
  905.         return Params;
  906.     }
  907.  
  908.  
  909. /* get the actual string argument contained in a command. NIL == not defined yet */
  910. char*                                    GetCommandStringArg(NoteObjectRec* Command)
  911.     {
  912.         CheckPtrExistence(Command);
  913.         ERROR(!IsItACommand(Command),PRERR(ForceAbort,
  914.             "GetCommandStringArg:  called on note"));
  915.         return Command->a.Command.StringArgument;
  916.     }
  917.  
  918.  
  919. /* get the first numeric argument contained in a command */
  920. long                                    GetCommandNumericArg1(NoteObjectRec* Command)
  921.     {
  922.         CheckPtrExistence(Command);
  923.         ERROR(!IsItACommand(Command),PRERR(ForceAbort,
  924.             "GetCommandNumericArg1:  called on note"));
  925.         return Command->a.Command.Argument1;
  926.     }
  927.  
  928.  
  929. /* get the second numeric argument contained in a command */
  930. long                                    GetCommandNumericArg2(NoteObjectRec* Command)
  931.     {
  932.         CheckPtrExistence(Command);
  933.         ERROR(!IsItACommand(Command),PRERR(ForceAbort,
  934.             "GetCommandNumericArg2:  called on note"));
  935.         return Command->a.Command.Argument2;
  936.     }
  937.  
  938.  
  939. /* get the third numeric argument contained in a command */
  940. long                                    GetCommandNumericArg3(NoteObjectRec* Command)
  941.     {
  942.         CheckPtrExistence(Command);
  943.         ERROR(!IsItACommand(Command),PRERR(ForceAbort,
  944.             "GetCommandNumericArg3:  called on note"));
  945.         return Command->a.Command.Argument3;
  946.     }
  947.  
  948.  
  949. /* put a new string into the command.  the command becomes owner of the string. */
  950. void                                    PutCommandStringArg(NoteObjectRec* Command, char* NewArg)
  951.     {
  952.         CheckPtrExistence(Command);
  953.         ERROR(!IsItACommand(Command),PRERR(ForceAbort,
  954.             "PutCommandStringArg:  called on note"));
  955.         CheckPtrExistence(NewArg);
  956.         ReleasePtr(Command->a.Command.StringArgument);
  957.         Command->a.Command.StringArgument = NewArg;
  958.     }
  959.  
  960.  
  961. /* put a new first numeric argument into the command */
  962. void                                    PutCommandNumericArg1(NoteObjectRec* Command, long NewValue)
  963.     {
  964.         CheckPtrExistence(Command);
  965.         ERROR(!IsItACommand(Command),PRERR(ForceAbort,
  966.             "PutCommandNumericArg1:  called on note"));
  967.         Command->a.Command.Argument1 = NewValue;
  968.     }
  969.  
  970.  
  971. /* put a new second numeric argument into the command */
  972. void                                    PutCommandNumericArg2(NoteObjectRec* Command, long NewValue)
  973.     {
  974.         CheckPtrExistence(Command);
  975.         ERROR(!IsItACommand(Command),PRERR(ForceAbort,
  976.             "PutCommandNumericArg2:  called on note"));
  977.         Command->a.Command.Argument2 = NewValue;
  978.     }
  979.  
  980.  
  981. /* put a new third numeric argument into the command */
  982. void                                    PutCommandNumericArg3(NoteObjectRec* Command, long NewValue)
  983.     {
  984.         CheckPtrExistence(Command);
  985.         ERROR(!IsItACommand(Command),PRERR(ForceAbort,
  986.             "PutCommandNumericArg3:  called on note"));
  987.         Command->a.Command.Argument3 = NewValue;
  988.     }
  989.  
  990.  
  991. /* get the pitch of a note */
  992. short                                    GetNotePitch(NoteObjectRec* Note)
  993.     {
  994.         CheckPtrExistence(Note);
  995.         ERROR(IsItACommand(Note),PRERR(ForceAbort,"GetNotePitch:  called on command"));
  996.         return Note->a.Note.Pitch;
  997.     }
  998.  
  999.  
  1000. /* get the portamento transition time for the note */
  1001. double                                GetNotePortamentoDuration(NoteObjectRec* Note)
  1002.     {
  1003.         CheckPtrExistence(Note);
  1004.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1005.             "GetNotePortamentoDuration:  called on command"));
  1006.         return SmallBCD2Double(Note->a.Note.PortamentoDuration);
  1007.     }
  1008.  
  1009.  
  1010. /* get the early/late adjustment factor for a note */
  1011. double                                GetNoteEarlyLateAdjust(NoteObjectRec* Note)
  1012.     {
  1013.         CheckPtrExistence(Note);
  1014.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1015.             "GetNoteEarlyLateAdjust:  called on command"));
  1016.         return SmallBCD2Double(Note->a.Note.EarlyLateAdjust);
  1017.     }
  1018.  
  1019.  
  1020. /* get the duration adjust value for a note */
  1021. double                                GetNoteDurationAdjust(NoteObjectRec* Note)
  1022.     {
  1023.         CheckPtrExistence(Note);
  1024.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1025.             "GetNoteDurationAdjust:  called on command"));
  1026.         return SmallBCD2Double(Note->a.Note.DurationAdjust);
  1027.     }
  1028.  
  1029.  
  1030. /* get a pointer to the note that this note ties to or NIL if there is no tie */
  1031. NoteObjectRec*                GetNoteTieTarget(NoteObjectRec* Note)
  1032.     {
  1033.         CheckPtrExistence(Note);
  1034.         ERROR(IsItACommand(Note),PRERR(ForceAbort,"GetNoteTieTarget:  called on command"));
  1035.         if (Note->a.Note.Tie != NIL)
  1036.             {
  1037.                 CheckPtrExistence(Note->a.Note.Tie);
  1038.             }
  1039.         return Note->a.Note.Tie;
  1040.     }
  1041.  
  1042.  
  1043. /* get the first release point position from a note */
  1044. double                                GetNoteReleasePoint1(NoteObjectRec* Note)
  1045.     {
  1046.         CheckPtrExistence(Note);
  1047.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1048.             "GetNoteReleasePoint1:  called on command"));
  1049.         return SmallBCD2Double(Note->a.Note.ReleasePoint1);
  1050.     }
  1051.  
  1052.  
  1053. /* get the second release point position from a note */
  1054. double                                GetNoteReleasePoint2(NoteObjectRec* Note)
  1055.     {
  1056.         CheckPtrExistence(Note);
  1057.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1058.             "GetNoteReleasePoint2:  called on command"));
  1059.         return SmallBCD2Double(Note->a.Note.ReleasePoint2);
  1060.     }
  1061.  
  1062.  
  1063. /* get the overall loudness factor for the note */
  1064. double                                GetNoteOverallLoudnessAdjustment(NoteObjectRec* Note)
  1065.     {
  1066.         CheckPtrExistence(Note);
  1067.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1068.             "GetNoteOverallLoudnessAdjustment:  called on command"));
  1069.         return SmallBCD2Double(Note->a.Note.OverallLoudnessAdjustment);
  1070.     }
  1071.  
  1072.  
  1073. /* get the stereo positioning for the note */
  1074. double                                GetNoteStereoPositioning(NoteObjectRec* Note)
  1075.     {
  1076.         CheckPtrExistence(Note);
  1077.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1078.             "GetNoteStereoPositioning:  called on command"));
  1079.         return SmallBCD2Double(Note->a.Note.StereoPositionAdjustment);
  1080.     }
  1081.  
  1082.  
  1083. /* get the surround positioning for the note */
  1084. double                                GetNoteSurroundPositioning(NoteObjectRec* Note)
  1085.     {
  1086.         CheckPtrExistence(Note);
  1087.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1088.             "GetNoteSurroundPositioning:  called on command"));
  1089.         return SmallBCD2Double(Note->a.Note.SurroundPositionAdjustment);
  1090.     }
  1091.  
  1092.  
  1093. /* get the first accent factor for the note */
  1094. double                                GetNoteAccent1(NoteObjectRec* Note)
  1095.     {
  1096.         CheckPtrExistence(Note);
  1097.         ERROR(IsItACommand(Note),PRERR(ForceAbort,"GetNoteAccent1:  called on command"));
  1098.         return SmallBCD2Double(Note->a.Note.Accent1);
  1099.     }
  1100.  
  1101.  
  1102. /* get the second accent factor for the note */
  1103. double                                GetNoteAccent2(NoteObjectRec* Note)
  1104.     {
  1105.         CheckPtrExistence(Note);
  1106.         ERROR(IsItACommand(Note),PRERR(ForceAbort,"GetNoteAccent2:  called on command"));
  1107.         return SmallBCD2Double(Note->a.Note.Accent2);
  1108.     }
  1109.  
  1110.  
  1111. /* get the third accent factor for the note */
  1112. double                                GetNoteAccent3(NoteObjectRec* Note)
  1113.     {
  1114.         CheckPtrExistence(Note);
  1115.         ERROR(IsItACommand(Note),PRERR(ForceAbort,"GetNoteAccent3:  called on command"));
  1116.         return SmallBCD2Double(Note->a.Note.Accent3);
  1117.     }
  1118.  
  1119.  
  1120. /* get the fourth accent factor for the note */
  1121. double                                GetNoteAccent4(NoteObjectRec* Note)
  1122.     {
  1123.         CheckPtrExistence(Note);
  1124.         ERROR(IsItACommand(Note),PRERR(ForceAbort,"GetNoteAccent4:  called on command"));
  1125.         return SmallBCD2Double(Note->a.Note.Accent4);
  1126.     }
  1127.  
  1128.  
  1129. /* get the pitch that the table selector should treat the note as using */
  1130. short                                    GetNoteMultisampleFalsePitch(NoteObjectRec* Note)
  1131.     {
  1132.         CheckPtrExistence(Note);
  1133.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1134.             "GetNoteMultisampleFalsePitch:  called on command"));
  1135.         return Note->a.Note.MultisamplePitchAsIf;
  1136.     }
  1137.  
  1138.  
  1139. /* get the pitch displacement depth adjust factor */
  1140. double                                GetNotePitchDisplacementDepthAdjust(NoteObjectRec* Note)
  1141.     {
  1142.         CheckPtrExistence(Note);
  1143.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1144.             "GetNotePitchDisplacementDepthAdjust:  called on command"));
  1145.         return SmallBCD2Double(Note->a.Note.PitchDisplacementDepthAdjustment);
  1146.     }
  1147.  
  1148.  
  1149. /* get the pitch displacement rate adjust factor for the note */
  1150. double                                GetNotePitchDisplacementRateAdjust(NoteObjectRec* Note)
  1151.     {
  1152.         CheckPtrExistence(Note);
  1153.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1154.             "GetNotePitchDisplacementRateAdjust:  called on command"));
  1155.         return SmallBCD2Double(Note->a.Note.PitchDisplacementRateAdjustment);
  1156.     }
  1157.  
  1158.  
  1159. /* get the pitch displacement envelope start point */
  1160. double                                GetNotePitchDisplacementStartPoint(NoteObjectRec* Note)
  1161.     {
  1162.         CheckPtrExistence(Note);
  1163.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1164.             "GetNotePitchDisplacementStartPoint:  called on command"));
  1165.         return SmallBCD2Double(Note->a.Note.PitchDisplacementStartPoint);
  1166.     }
  1167.  
  1168.  
  1169. /* get the hurryup factor for the note */
  1170. double                                GetNoteHurryUpFactor(NoteObjectRec* Note)
  1171.     {
  1172.         CheckPtrExistence(Note);
  1173.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1174.             "GetNoteHurryUpFactor:  called on command"));
  1175.         return SmallBCD2Double(Note->a.Note.HurryUpFactor);
  1176.     }
  1177.  
  1178.  
  1179. /* get the detuning adjustment for the note */
  1180. double                                GetNoteDetuning(NoteObjectRec* Note)
  1181.     {
  1182.         CheckPtrExistence(Note);
  1183.         ERROR(IsItACommand(Note),PRERR(ForceAbort,"GetNoteDetuning:  called on command"));
  1184.         return SmallBCD2Double(Note->a.Note.Detuning);
  1185.     }
  1186.  
  1187.  
  1188. /* change the pitch of a note */
  1189. void                                    PutNotePitch(NoteObjectRec* Note, short NewPitch)
  1190.     {
  1191.         CheckPtrExistence(Note);
  1192.         ERROR(IsItACommand(Note),PRERR(ForceAbort,"PutNotePitch:  called on command"));
  1193.         ERROR((NewPitch < 0) || (NewPitch >= NUMNOTES),PRERR(ForceAbort,
  1194.             "PutNotePitch:  pitch value is out of range"));
  1195.         Note->a.Note.Pitch = NewPitch;
  1196.     }
  1197.  
  1198.  
  1199. /* get the portamento transition time for the note */
  1200. void                                    PutNotePortamentoDuration(NoteObjectRec* Note,
  1201.                                                 double NewPortamentoDuration)
  1202.     {
  1203.         CheckPtrExistence(Note);
  1204.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1205.             "PutNotePortamentoDuration:  called on command"));
  1206.         Note->a.Note.PortamentoDuration = Double2SmallBCD(NewPortamentoDuration);
  1207.     }
  1208.  
  1209.  
  1210. /* change the early/late adjustment factor for a note */
  1211. void                                    PutNoteEarlyLateAdjust(NoteObjectRec* Note, double NewEarlyLate)
  1212.     {
  1213.         CheckPtrExistence(Note);
  1214.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1215.             "PutNoteEarlyLateAdjust:  called on command"));
  1216.         Note->a.Note.EarlyLateAdjust = Double2SmallBCD(NewEarlyLate);
  1217.     }
  1218.  
  1219.  
  1220. /* change the duration adjust value for a note */
  1221. void                                    PutNoteDurationAdjust(NoteObjectRec* Note,
  1222.                                                 double NewDurationAdjust)
  1223.     {
  1224.         CheckPtrExistence(Note);
  1225.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1226.             "PutNoteDurationAdjust:  called on command"));
  1227.         Note->a.Note.DurationAdjust = Double2SmallBCD(NewDurationAdjust);
  1228.     }
  1229.  
  1230.  
  1231. /* change the pointer to the note that this note ties to. */
  1232. void                                    PutNoteTieTarget(NoteObjectRec* Note, NoteObjectRec* NewTieTarget)
  1233.     {
  1234.         CheckPtrExistence(Note);
  1235.         ERROR(IsItACommand(Note),PRERR(ForceAbort,"PutNoteTieTarget:  called on command"));
  1236.         if (NewTieTarget != NIL)
  1237.             {
  1238.                 CheckPtrExistence(NewTieTarget);
  1239.             }
  1240.         Note->a.Note.Tie = NewTieTarget;
  1241.     }
  1242.  
  1243.  
  1244. /* change the first release point position from a note */
  1245. void                                    PutNoteReleasePoint1(NoteObjectRec* Note, double NewReleasePoint1)
  1246.     {
  1247.         CheckPtrExistence(Note);
  1248.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1249.             "PutNoteReleasePoint1:  called on command"));
  1250.         Note->a.Note.ReleasePoint1 = Double2SmallBCD(NewReleasePoint1);
  1251.     }
  1252.  
  1253.  
  1254. /* change the second release point position from a note */
  1255. void                                    PutNoteReleasePoint2(NoteObjectRec* Note, double NewReleasePoint2)
  1256.     {
  1257.         CheckPtrExistence(Note);
  1258.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1259.             "PutNoteReleasePoint2:  called on command"));
  1260.         Note->a.Note.ReleasePoint2 = Double2SmallBCD(NewReleasePoint2);
  1261.     }
  1262.  
  1263.  
  1264. /* change the overall loudness factor for the note */
  1265. void                                    PutNoteOverallLoudnessAdjustment(NoteObjectRec* Note,
  1266.                                                 double NewLoudnessAdjust)
  1267.     {
  1268.         CheckPtrExistence(Note);
  1269.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1270.             "PutNoteOverallLoudnessAdjustment:  called on command"));
  1271.         Note->a.Note.OverallLoudnessAdjustment = Double2SmallBCD(NewLoudnessAdjust);
  1272.     }
  1273.  
  1274.  
  1275. /* change the stereo positioning for the note */
  1276. void                                    PutNoteStereoPositioning(NoteObjectRec* Note,
  1277.                                                 double NewStereoPosition)
  1278.     {
  1279.         CheckPtrExistence(Note);
  1280.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1281.             "PutNoteStereoPositioning:  called on command"));
  1282.         Note->a.Note.StereoPositionAdjustment = Double2SmallBCD(NewStereoPosition);
  1283.     }
  1284.  
  1285.  
  1286. /* change the surround positioning for the note */
  1287. void                                    PutNoteSurroundPositioning(NoteObjectRec* Note,
  1288.                                                 double NewSurroundPosition)
  1289.     {
  1290.         CheckPtrExistence(Note);
  1291.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1292.             "PutNoteSurroundPositioning:  called on command"));
  1293.         Note->a.Note.SurroundPositionAdjustment = Double2SmallBCD(NewSurroundPosition);
  1294.     }
  1295.  
  1296.  
  1297. /* change the first accent factor for the note */
  1298. void                                    PutNoteAccent1(NoteObjectRec* Note, double NewAccent1)
  1299.     {
  1300.         CheckPtrExistence(Note);
  1301.         ERROR(IsItACommand(Note),PRERR(ForceAbort,"PutNoteAccent1:  called on command"));
  1302.         Note->a.Note.Accent1 = Double2SmallBCD(NewAccent1);
  1303.     }
  1304.  
  1305.  
  1306. /* change the second accent factor for the note */
  1307. void                                    PutNoteAccent2(NoteObjectRec* Note, double NewAccent2)
  1308.     {
  1309.         CheckPtrExistence(Note);
  1310.         ERROR(IsItACommand(Note),PRERR(ForceAbort,"PutNoteAccent2:  called on command"));
  1311.         Note->a.Note.Accent2 = Double2SmallBCD(NewAccent2);
  1312.     }
  1313.  
  1314.  
  1315. /* change the third accent factor for the note */
  1316. void                                    PutNoteAccent3(NoteObjectRec* Note, double NewAccent3)
  1317.     {
  1318.         CheckPtrExistence(Note);
  1319.         ERROR(IsItACommand(Note),PRERR(ForceAbort,"PutNoteAccent3:  called on command"));
  1320.         Note->a.Note.Accent3 = Double2SmallBCD(NewAccent3);
  1321.     }
  1322.  
  1323.  
  1324. /* change the fourth accent factor for the note */
  1325. void                                    PutNoteAccent4(NoteObjectRec* Note, double NewAccent4)
  1326.     {
  1327.         CheckPtrExistence(Note);
  1328.         ERROR(IsItACommand(Note),PRERR(ForceAbort,"PutNoteAccent4:  called on command"));
  1329.         Note->a.Note.Accent4 = Double2SmallBCD(NewAccent4);
  1330.     }
  1331.  
  1332.  
  1333. /* change the pitch that the table selector should treat the note as using */
  1334. void                                    PutNoteMultisampleFalsePitch(NoteObjectRec* Note,
  1335.                                                 short NewFalsePitch)
  1336.     {
  1337.         CheckPtrExistence(Note);
  1338.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1339.             "PutNoteMultisampleFalsePitch:  called on command"));
  1340.         Note->a.Note.MultisamplePitchAsIf = NewFalsePitch;
  1341.     }
  1342.  
  1343.  
  1344. /* change the pitch displacement depth adjust factor for the note */
  1345. void                                    PutNotePitchDisplacementDepthAdjust(NoteObjectRec* Note,
  1346.                                                 double NewPitchDisplacementDepthAdjust)
  1347.     {
  1348.         CheckPtrExistence(Note);
  1349.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1350.             "PutNotePitchDisplacementDepthAdjust:  called on command"));
  1351.         Note->a.Note.PitchDisplacementDepthAdjustment
  1352.             = Double2SmallBCD(NewPitchDisplacementDepthAdjust);
  1353.     }
  1354.  
  1355.  
  1356. /* change the pitch displacement rate adjust factor for the note */
  1357. void                                    PutNotePitchDisplacementRateAdjust(NoteObjectRec* Note,
  1358.                                                 double NewPitchDisplacementRateAdjust)
  1359.     {
  1360.         CheckPtrExistence(Note);
  1361.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1362.             "PutNotePitchDisplacementRateAdjust:  called on command"));
  1363.         Note->a.Note.PitchDisplacementRateAdjustment
  1364.             = Double2SmallBCD(NewPitchDisplacementRateAdjust);
  1365.     }
  1366.  
  1367.  
  1368. /* change the pitch displacement envelope start point */
  1369. void                                    PutNotePitchDisplacementStartPoint(NoteObjectRec* Note,
  1370.                                                 double NewPitchDisplacementStartPoint)
  1371.     {
  1372.         CheckPtrExistence(Note);
  1373.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1374.             "PutNotePitchDisplacementStartPoint:  called on command"));
  1375.         Note->a.Note.PitchDisplacementStartPoint
  1376.             = Double2SmallBCD(NewPitchDisplacementStartPoint);
  1377.     }
  1378.  
  1379.  
  1380. /* change the hurryup factor for the note */
  1381. void                                    PutNoteHurryUpFactor(NoteObjectRec* Note, double NewHurryUpFactor)
  1382.     {
  1383.         CheckPtrExistence(Note);
  1384.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1385.             "PutNoteHurryUpFactor:  called on command"));
  1386.         Note->a.Note.HurryUpFactor = Double2SmallBCD(NewHurryUpFactor);
  1387.     }
  1388.  
  1389.  
  1390. /* change the detuning adjustment for the note */
  1391. void                                    PutNoteDetuning(NoteObjectRec* Note, double NewDetuning)
  1392.     {
  1393.         CheckPtrExistence(Note);
  1394.         ERROR(IsItACommand(Note),PRERR(ForceAbort,"PutNoteDetuning:  called on command"));
  1395.         Note->a.Note.Detuning = Double2SmallBCD(NewDetuning);
  1396.     }
  1397.  
  1398.  
  1399. /* get the opcode for a command */
  1400. unsigned long                    GetCommandOpcode(NoteObjectRec* Command)
  1401.     {
  1402.         CheckPtrExistence(Command);
  1403.         ERROR(!IsItACommand(Command),PRERR(ForceAbort,"GetCommandOpcode:  called on note"));
  1404.         return Command->Flags & ~eCommandFlag;
  1405.     }
  1406.  
  1407.  
  1408. /* put a new opcode in the command */
  1409. void                                    PutCommandOpcode(NoteObjectRec* Command, unsigned long NewOpcode)
  1410.     {
  1411.         CheckPtrExistence(Command);
  1412.         ERROR(!IsItACommand(Command),PRERR(ForceAbort,"PutCommandOpcode:  called on note"));
  1413.         ERROR((NewOpcode & eCommandFlag) != 0,PRERR(AllowResume,
  1414.             "PutCommandOpcode:  command flag is set on new opcode word"));
  1415.         Command->Flags = (Command->Flags & eCommandFlag) | NewOpcode;
  1416.     }
  1417.  
  1418.  
  1419. /* get the duration of a note */
  1420. unsigned long                    GetNoteDuration(NoteObjectRec* Note)
  1421.     {
  1422.         CheckPtrExistence(Note);
  1423.         ERROR(IsItACommand(Note),PRERR(ForceAbort,"GetNoteDuration:  called on command"));
  1424.         return (Note->Flags & eDurationMask);
  1425.     }
  1426.  
  1427.  
  1428. /* get the duration division of a note */
  1429. unsigned long                    GetNoteDurationDivision(NoteObjectRec* Note)
  1430.     {
  1431.         CheckPtrExistence(Note);
  1432.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1433.             "GetNoteDurationDivision:  called on command"));
  1434.         return (Note->Flags & eDivisionMask);
  1435.     }
  1436.  
  1437.  
  1438. /* get the dot status of a note */
  1439. MyBoolean                            GetNoteDotStatus(NoteObjectRec* Note)
  1440.     {
  1441.         CheckPtrExistence(Note);
  1442.         ERROR(IsItACommand(Note),PRERR(ForceAbort,"GetNoteDotStatus:  called on command"));
  1443.         return ((Note->Flags & eDotModifier) != 0);
  1444.     }
  1445.  
  1446.  
  1447. /* get the flat or sharp status of a note */
  1448. unsigned long                    GetNoteFlatOrSharpStatus(NoteObjectRec* Note)
  1449.     {
  1450.         CheckPtrExistence(Note);
  1451.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1452.             "GetNoteFlatOrSharpStatus:  called on command"));
  1453.         return (Note->Flags & (eFlatModifier | eSharpModifier));
  1454.     }
  1455.  
  1456.  
  1457. /* get the rest status of a note */
  1458. MyBoolean                            GetNoteIsItARest(NoteObjectRec* Note)
  1459.     {
  1460.         CheckPtrExistence(Note);
  1461.         ERROR(IsItACommand(Note),PRERR(ForceAbort,"GetNoteIsItARest:  called on command"));
  1462.         return ((Note->Flags & eRestModifier) != 0);
  1463.     }
  1464.  
  1465.  
  1466. /* get the first release point origin of a note */
  1467. unsigned long                    GetNoteRelease1Origin(NoteObjectRec* Note)
  1468.     {
  1469.         CheckPtrExistence(Note);
  1470.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1471.             "GetNoteRelease1Origin:  called on command"));
  1472.         return (Note->Flags & eRelease1OriginMask);
  1473.     }
  1474.  
  1475.  
  1476. /* get the second release point origin of a note */
  1477. unsigned long                    GetNoteRelease2Origin(NoteObjectRec* Note)
  1478.     {
  1479.         CheckPtrExistence(Note);
  1480.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1481.             "GetNoteRelease2Origin:  called on command"));
  1482.         return (Note->Flags & eRelease2OriginMask);
  1483.     }
  1484.  
  1485.  
  1486. /* get the third release from start instead of end flag of a note */
  1487. MyBoolean                            GetNoteRelease3FromStartInsteadOfEnd(NoteObjectRec* Note)
  1488.     {
  1489.         CheckPtrExistence(Note);
  1490.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1491.             "GetNoteRelease3FromStartInsteadOfEnd:  called on command"));
  1492.         return ((Note->Flags & eRelease3FromStartNotEnd) != 0);
  1493.     }
  1494.  
  1495.  
  1496. /* get the pitch displacement origin of a note */
  1497. unsigned long                    GetNotePitchDisplacementStartOrigin(NoteObjectRec* Note)
  1498.     {
  1499.         CheckPtrExistence(Note);
  1500.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1501.             "GetNotePitchDisplacementStartOrigin:  called on command"));
  1502.         return (Note->Flags & ePitchDisplacementStartOriginMask);
  1503.     }
  1504.  
  1505.  
  1506. /* get the pitch displacement depth pitch conversion mode of a note */
  1507. unsigned long                    GetNotePitchDisplacementDepthConversionMode(NoteObjectRec* Note)
  1508.     {
  1509.         CheckPtrExistence(Note);
  1510.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1511.             "GetNotePitchDisplacementDepthConversionMode:  called on command"));
  1512.         return (Note->Flags & ePitchDisplacementDepthModeMask);
  1513.     }
  1514.  
  1515.  
  1516. /* get the detuning pitch conversion mode of a note */
  1517. unsigned long                    GetNoteDetuneConversionMode(NoteObjectRec* Note)
  1518.     {
  1519.         CheckPtrExistence(Note);
  1520.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1521.             "GetNoteDetuneConversionMode:  called on command"));
  1522.         return (Note->Flags & eDetuningModeMask);
  1523.     }
  1524.  
  1525.  
  1526. /* get the retrigger envelope on tie status of a note */
  1527. MyBoolean                            GetNoteRetriggerEnvelopesOnTieStatus(NoteObjectRec* Note)
  1528.     {
  1529.         CheckPtrExistence(Note);
  1530.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1531.             "GetNoteRetriggerEnvelopesOnTieStatus:  called on command"));
  1532.         return ((Note->Flags & eRetriggerEnvelopesOnTieFlag) != 0);
  1533.     }
  1534.  
  1535.  
  1536. /* get the duration adjustment mode of a note */
  1537. unsigned long                    GetNoteDurationAdjustMode(NoteObjectRec* Note)
  1538.     {
  1539.         CheckPtrExistence(Note);
  1540.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1541.             "GetNoteDurationAdjustMode:  called on command"));
  1542.         return (Note->Flags & eDurationAdjustMask);
  1543.     }
  1544.  
  1545.  
  1546. /* get a flag indicating that portamento should use Hertz instead of halfsteps */
  1547. MyBoolean                            GetNotePortamentoHertzNotHalfstepsFlag(NoteObjectRec* Note)
  1548.     {
  1549.         CheckPtrExistence(Note);
  1550.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1551.             "GetNotePortamentoHertzNotHalfstepsFlag:  called on command"));
  1552.         return ((Note->Flags & ePortamentoHertzNotHalfsteps) != 0);
  1553.     }
  1554.  
  1555.  
  1556. /* change the duration of a note */
  1557. void                                    PutNoteDuration(NoteObjectRec* Note, unsigned long NewDuration)
  1558.     {
  1559.         CheckPtrExistence(Note);
  1560.         ERROR(IsItACommand(Note),PRERR(ForceAbort,"PutNoteDuration:  called on command"));
  1561.         ERROR((NewDuration != e64thNote) && (NewDuration != e32ndNote)
  1562.             && (NewDuration != e16thNote) && (NewDuration != e8thNote)
  1563.             && (NewDuration != e4thNote) && (NewDuration != e2ndNote)
  1564.             && (NewDuration != eWholeNote) && (NewDuration != eDoubleNote)
  1565.             && (NewDuration != eQuadNote),PRERR(ForceAbort,
  1566.             "PutNoteDuration:  bad duration value"));
  1567.         Note->Flags = (Note->Flags & ~eDurationMask) | NewDuration;
  1568.     }
  1569.  
  1570.  
  1571. /* change the duration division of a note */
  1572. void                                    PutNoteDurationDivision(NoteObjectRec* Note,
  1573.                                                 unsigned long NewDivision)
  1574.     {
  1575.         CheckPtrExistence(Note);
  1576.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1577.             "PutNoteDurationDivision:  called on command"));
  1578.         ERROR((NewDivision != eDiv1Modifier) && (NewDivision != eDiv3Modifier)
  1579.             && (NewDivision != eDiv5Modifier) && (NewDivision != eDiv7Modifier),
  1580.             PRERR(ForceAbort,"PutNoteDurationDivision:  bad division value"));
  1581.         Note->Flags = (Note->Flags & ~eDivisionMask) | NewDivision;
  1582.     }
  1583.  
  1584.  
  1585. /* change the dot status of a note */
  1586. void                                    PutNoteDotStatus(NoteObjectRec* Note, MyBoolean HasADot)
  1587.     {
  1588.         CheckPtrExistence(Note);
  1589.         ERROR(IsItACommand(Note),PRERR(ForceAbort,"PutNoteDotStatus:  called on command"));
  1590.         if (HasADot)
  1591.             {
  1592.                 Note->Flags |= eDotModifier;
  1593.             }
  1594.          else
  1595.             {
  1596.                 Note->Flags &= ~eDotModifier;
  1597.             }
  1598.     }
  1599.  
  1600.  
  1601. /* change the flat or sharp status of a note */
  1602. void                                    PutNoteFlatOrSharpStatus(NoteObjectRec* Note,
  1603.                                                 unsigned long NewFlatOrSharpStatus)
  1604.     {
  1605.         CheckPtrExistence(Note);
  1606.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1607.             "PutNoteFlatOrSharpStatus:  called on command"));
  1608.         ERROR((NewFlatOrSharpStatus != 0) && (NewFlatOrSharpStatus != eFlatModifier)
  1609.             && (NewFlatOrSharpStatus != eSharpModifier),PRERR(ForceAbort,
  1610.             "PutNoteFlatOrSharpStatus:  bad sharp or flat status"));
  1611.         Note->Flags = (Note->Flags & ~(eSharpModifier | eFlatModifier))
  1612.             | NewFlatOrSharpStatus;
  1613.     }
  1614.  
  1615.  
  1616. /* change the rest status of a note */
  1617. void                                    PutNoteIsItARest(NoteObjectRec* Note, MyBoolean IsARest)
  1618.     {
  1619.         CheckPtrExistence(Note);
  1620.         ERROR(IsItACommand(Note),PRERR(ForceAbort,"PutNoteIsItARest:  called on command"));
  1621.         if (IsARest)
  1622.             {
  1623.                 Note->Flags |= eRestModifier;
  1624.             }
  1625.          else
  1626.             {
  1627.                 Note->Flags &= ~eRestModifier;
  1628.             }
  1629.     }
  1630.  
  1631.  
  1632. /* change the first release point origin of a note */
  1633. void                                    PutNoteRelease1Origin(NoteObjectRec* Note,
  1634.                                                 unsigned long NewReleasePoint1Origin)
  1635.     {
  1636.         CheckPtrExistence(Note);
  1637.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1638.             "PutNoteRelease1Origin:  called on command"));
  1639.         ERROR((NewReleasePoint1Origin != eRelease1FromDefault)
  1640.             && (NewReleasePoint1Origin != eRelease1FromStart)
  1641.             && (NewReleasePoint1Origin != eRelease1FromEnd),PRERR(ForceAbort,
  1642.             "PutNoteRelease1Origin:  bad origin value"));
  1643.         Note->Flags = (Note->Flags & ~eRelease1OriginMask) | NewReleasePoint1Origin;
  1644.     }
  1645.  
  1646.  
  1647. /* change the second release point origin of a note */
  1648. void                                    PutNoteRelease2Origin(NoteObjectRec* Note,
  1649.                                                 unsigned long NewReleasePoitn2Origin)
  1650.     {
  1651.         CheckPtrExistence(Note);
  1652.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1653.             "PutNoteRelease2Origin:  called on command"));
  1654.         ERROR((NewReleasePoitn2Origin != eRelease2FromDefault)
  1655.             && (NewReleasePoitn2Origin != eRelease2FromStart)
  1656.             && (NewReleasePoitn2Origin != eRelease2FromEnd),PRERR(ForceAbort,
  1657.             "PutNoteRelease2Origin:  bad origin value"));
  1658.         Note->Flags = (Note->Flags & ~eRelease2OriginMask) | NewReleasePoitn2Origin;
  1659.     }
  1660.  
  1661.  
  1662. /* change the third release from start instead of end flag of a note */
  1663. void                                    PutNoteRelease3FromStartInsteadOfEnd(NoteObjectRec* Note,
  1664.                                                 MyBoolean ShouldWeReleasePoint3FromStartInsteadOfEnd)
  1665.     {
  1666.         CheckPtrExistence(Note);
  1667.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1668.             "PutNoteRelease3FromStartInsteadOfEnd:  called on command"));
  1669.         if (ShouldWeReleasePoint3FromStartInsteadOfEnd)
  1670.             {
  1671.                 Note->Flags |= eRelease3FromStartNotEnd;
  1672.             }
  1673.          else
  1674.             {
  1675.                 Note->Flags &= ~eRelease3FromStartNotEnd;
  1676.             }
  1677.     }
  1678.  
  1679.  
  1680. /* change the pitch displacement origin of a note */
  1681. void                                    PutNotePitchDisplacementStartOrigin(NoteObjectRec* Note,
  1682.                                                 unsigned long NewPitchDisplacementStartOrigin)
  1683.     {
  1684.         CheckPtrExistence(Note);
  1685.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1686.             "PutNotePitchDisplacementStartOrigin:  called on command"));
  1687.         ERROR((NewPitchDisplacementStartOrigin != ePitchDisplacementStartFromDefault)
  1688.             && (NewPitchDisplacementStartOrigin != ePitchDisplacementStartFromStart)
  1689.             && (NewPitchDisplacementStartOrigin != ePitchDisplacementStartFromEnd),
  1690.             PRERR(ForceAbort,"PutNotePitchDisplacementStartOrigin:  bad origin value"));
  1691.         Note->Flags = (Note->Flags & ~ePitchDisplacementStartOriginMask)
  1692.             | NewPitchDisplacementStartOrigin;
  1693.     }
  1694.  
  1695.  
  1696. /* change the pitch displacement depth pitch conversion mode of a note */
  1697. void                                    PutNotePitchDisplacementDepthConversionMode(NoteObjectRec* Note,
  1698.                                                 unsigned long NewPitchDisplacementDepthConversionMode)
  1699.     {
  1700.         CheckPtrExistence(Note);
  1701.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1702.             "PutNotePitchDisplacementDepthConversionMode:  called on command"));
  1703.         ERROR((NewPitchDisplacementDepthConversionMode != ePitchDisplacementDepthModeDefault)
  1704.             && (NewPitchDisplacementDepthConversionMode != ePitchDisplacementDepthModeHalfSteps)
  1705.             && (NewPitchDisplacementDepthConversionMode != ePitchDisplacementDepthModeHertz),
  1706.             PRERR(ForceAbort,"PutNotePitchDisplacementDepthConversionMode:  bad mode value"));
  1707.         Note->Flags = (Note->Flags & ~ePitchDisplacementDepthModeMask)
  1708.             | NewPitchDisplacementDepthConversionMode;
  1709.     }
  1710.  
  1711.  
  1712. /* change the detuning pitch conversion mode of a note */
  1713. void                                    PutNoteDetuneConversionMode(NoteObjectRec* Note,
  1714.                                                 unsigned long NewDetuneConversionMode)
  1715.     {
  1716.         CheckPtrExistence(Note);
  1717.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1718.             "PutNoteDetuneConversionMode:  called on command"));
  1719.         ERROR((NewDetuneConversionMode != eDetuningModeDefault)
  1720.             && (NewDetuneConversionMode != eDetuningModeHalfSteps)
  1721.             && (NewDetuneConversionMode != eDetuningModeHertz),PRERR(ForceAbort,
  1722.             "PutNoteDetuneConversionMode:  bad mode value"));
  1723.         Note->Flags = (Note->Flags & ~eDetuningModeMask) | NewDetuneConversionMode;
  1724.     }
  1725.  
  1726.  
  1727. /* change the retrigger envelope on tie status of a note */
  1728. void                                    PutNoteRetriggerEnvelopesOnTieStatus(NoteObjectRec* Note,
  1729.                                                 MyBoolean ShouldWeRetriggerEnvelopesOnTie)
  1730.     {
  1731.         CheckPtrExistence(Note);
  1732.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1733.             "PutNoteRetriggerEnvelopesOnTieStatus:  called on command"));
  1734.         if (ShouldWeRetriggerEnvelopesOnTie)
  1735.             {
  1736.                 Note->Flags |= eRetriggerEnvelopesOnTieFlag;
  1737.             }
  1738.          else
  1739.             {
  1740.                 Note->Flags &= ~eRetriggerEnvelopesOnTieFlag;
  1741.             }
  1742.     }
  1743.  
  1744.  
  1745. /* change the duration adjustment mode of a note */
  1746. void                                    PutNoteDurationAdjustMode(NoteObjectRec* Note,
  1747.                                                 unsigned long NewDurationAdjustMode)
  1748.     {
  1749.         CheckPtrExistence(Note);
  1750.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1751.             "GetNoteDurationAdjustMode:  called on command"));
  1752.         ERROR((NewDurationAdjustMode != eDurationAdjustDefault)
  1753.             && (NewDurationAdjustMode != eDurationAdjustAdditive)
  1754.             && (NewDurationAdjustMode != eDurationAdjustMultiplicative),PRERR(ForceAbort,
  1755.             "PutNoteDurationAdjustMode:  bad value"));
  1756.         Note->Flags = (Note->Flags & ~eDurationAdjustMask) | NewDurationAdjustMode;
  1757.     }
  1758.  
  1759.  
  1760. /* change the flag indicating that portamento should use Hertz instead of halfsteps */
  1761. void                                    PutNotePortamentoHertzNotHalfstepsFlag(NoteObjectRec* Note,
  1762.                                                 MyBoolean ShouldWeUseHertzInsteadOfHalfsteps)
  1763.     {
  1764.         CheckPtrExistence(Note);
  1765.         ERROR(IsItACommand(Note),PRERR(ForceAbort,
  1766.             "PutNotePortamentoHertzNotHalfstepsFlag:  called on command"));
  1767.         if (ShouldWeUseHertzInsteadOfHalfsteps)
  1768.             {
  1769.                 Note->Flags |= ePortamentoHertzNotHalfsteps;
  1770.             }
  1771.          else
  1772.             {
  1773.                 Note->Flags &= ~ePortamentoHertzNotHalfsteps;
  1774.             }
  1775.     }
  1776.  
  1777.  
  1778. /* Note Object Subblock Format: */
  1779. /* Each note/command has the following field: */
  1780. /*   4-byte unsigned little endian opcode field */
  1781. /*       for a command, the high bit will be 1 and the remaining bits will */
  1782. /*       be the opcode.  for a note, the high bit will be 0. */
  1783.  
  1784. /* Remainder of Note Variant Subblock: */
  1785. /*   definitions for the remaining bits in the opcode field */
  1786. /*       bits 0-3:  duration integer. */
  1787. /*         0001 = 64th note */
  1788. /*         0010 = 32nd note */
  1789. /*         0011 = 16th note */
  1790. /*         0100 = 8th note */
  1791. /*         0101 = quarter note */
  1792. /*         0110 = half note */
  1793. /*         0111 = whole note */
  1794. /*         1000 = double note */
  1795. /*         1001 = quad note */
  1796. /*         all other values are not permitted */
  1797. /*       bits 4-5:  division mask */
  1798. /*         00 = divide duration by 1 (no change in duration) */
  1799. /*         01 = divide duration by 3 (triplets) */
  1800. /*         10 = divide duration by 5 */
  1801. /*         11 = divide duration by 7 */
  1802. /*       bit 6:  dotted note flag (1 = dot) */
  1803. /*       bit 7:  flat modifier (1 = flat);  this is used for notation only */
  1804. /*         at most 1 of the flat or sharp modifiers can be set */
  1805. /*       bit 8:  sharp modifier (1 = sharp);  this is used for notation only */
  1806. /*         at most 1 of the flat or sharp modifiers can be set */
  1807. /*       bit 9:  rest modifier (1 = rest instead of note) */
  1808. /*       bits 10-11:  release point 1 origin */
  1809. /*         01 = use default origin */
  1810. /*         10 = measure release point from start of note */
  1811. /*         11 = measure release point from end of note */
  1812. /*         other values are not permitted */
  1813. /*       bits 12-13:  release point 2 origin */
  1814. /*         01 = use default origin */
  1815. /*         10 = measure release point from start of note */
  1816. /*         11 = measure release point from end of note */
  1817. /*         other values are not permitted */
  1818. /*       bit 14:  release point 3 origin (1 = from start instead of end) */
  1819. /*         0 = release 3 occurs at end of note */
  1820. /*         1 = release 3 occurs at start of note */
  1821. /*       bits 15-16:  pitch displacement start point origin */
  1822. /*         01 = use default origin */
  1823. /*         10 = pitch displacement start point from start of note */
  1824. /*         11 = pitch displacement start point from end of note */
  1825. /*         other values are not permitted */
  1826. /*       bits 17-18:  pitch displacement depth modulation mode */
  1827. /*         01 = use default pitch modulation scale */
  1828. /*         10 = treat modulation index as half-step number */
  1829. /*         11 = treat modulation index as hertz */
  1830. /*         other values are not permitted */
  1831. /*       bits 19-20:  detuning mode */
  1832. /*         01 = use default treat detuning scale */
  1833. /*         10 = treat detuning value as half-step number */
  1834. /*         11 = treat detuning value as hertz */
  1835. /*         other values are not permitted */
  1836. /*       bits 21-22:  note duration adjustment scale */
  1837. /*         01 = use default duration adjustment scale */
  1838. /*         10 = add duration adjustment to the duration */
  1839. /*         11 = multiply the duration adjustment by the duration */
  1840. /*         other values are not permitted */
  1841. /*       bit 23:  retrigger envelopes on tie flag */
  1842. /*       bit 24:  portamento linear in hertz instead of half steps (1 = hertz) */
  1843. /*       bits 25-31:  set to zero! */
  1844. /*   2-byte signed little endian pitch index */
  1845. /*       should be a value in the range 0..383.  Middle C (261.6 Hertz) = 192 */
  1846. /*   2-byte little endian small integer coded decimal portamento duration. */
  1847. /*       this determines how long a portamento will last, in fractions of a quarter */
  1848. /*       note.  it only has effect if the note is the target of a tie.  a value of */
  1849. /*       0 means instantaneous, i.e. no portamento. */
  1850. /*       A small integer coded decimal is the decimal * 1000 with a range */
  1851. /*       of -29.999 to 29.999 */
  1852. /*   2-byte little endian small integer coded decimal early/late adjustment */
  1853. /*       this determines the displacement in time of the occurrence of the note */
  1854. /*       in frations of a quarter note. */
  1855. /*   2-byte little endian small integer coded decimal duration adjustment */
  1856. /*       this value changes the duration of the note by being added to the */
  1857. /*       duration or being multiplied by the duration. */
  1858. /*   2-byte little endian small integer coded decimal release point 1 location */
  1859. /*       this determines when the release of the first sustain/loop will occur */
  1860. /*       in fractions of the current note's duration.  it is relative to the origin */
  1861. /*       as determined by the opcode field. */
  1862. /*   2-byte little endian small integer coded decimal release point 2 location */
  1863. /*       this determines when the release of the second sustain/loop will occur. */
  1864. /*   2-byte little endian small integer coded decimal overall loudness adjustment */
  1865. /*       this factor scales the total volume output of the oscillators for this */
  1866. /*       particular note.  It is multiplied, so a value of 1 makes no change in */
  1867. /*       loudness. */
  1868. /*   2-byte little endian small integer coded decimal stereo position adjustment. */
  1869. /*       this value adjusts where the sound will be located in stereo.  -1 is */
  1870. /*       the far left, 1 is the far right, and 0 is center. */
  1871. /*   2-byte little endian small integer coded decimal surround position adjustment. */
  1872. /*       this value adjusts where the sound will be located in surround sound.  */
  1873. /*       1 is front and -1 is rear. */
  1874. /*   2-byte little endian small integer coded decimal accent 1 value */
  1875. /*   2-byte little endian small integer coded decimal accent 2 value */
  1876. /*   2-byte little endian small integer coded decimal accent 3 value */
  1877. /*   2-byte little endian small integer coded decimal accent 4 value */
  1878. /*   2-byte little endian fake pitch value */
  1879. /*       this value has a range of -1..383.  If it is not -1, then it will be used */
  1880. /*       to determine which sample a multisampled oscillator will use.  If it is -1 */
  1881. /*       then the actual pitch will be used to select a sample. */
  1882. /*   2-byte little endian small integer coded decimal pitch disp depth adjustment */
  1883. /*       this adjusts the maximum amplitude of the pitch displacement depth */
  1884. /*       oscillator (vibrato).  The value has units of either half steps or hertz */
  1885. /*       depending on the setting in the opcode word. */
  1886. /*   2-byte little endian small integer coded decimal pitch displ rate adjustment */
  1887. /*       this adjusts the maximum amplitude of the pitch displacement rate */
  1888. /*       oscillator. the units are periods per second. */
  1889. /*   2-byte little endian small integer coded decimal pitch displ start point adjust */
  1890. /*       this value adjusts when the pitch displacement envelopes start.  the */
  1891. /*       location is from start or end of note, depending on the opcode settings, and */
  1892. /*       is in fractions of the current note's duration. */
  1893. /*   2-byte little endian small integer coded decimal hurry-up factor */
  1894. /*       this factor scales the total speed at which all envelopes change.  this is */
  1895. /*       multiplicative, so a value of 1 makes no change, and smaller values make */
  1896. /*       transitions go faster. */
  1897. /*   2-byte little endian small integer coded decimal detuning value */
  1898. /*       this value is added to the pitch of the note to detune.  its units are */
  1899. /*       either hertz or half steps depending on the opcode word. */
  1900.  
  1901. /* Remainder of Command Variant Subblock: */
  1902. /*   lower 31 bits of the command opcode: */
  1903. /*        16 = restore tempo */
  1904. /*        17 = set tempo */
  1905. /*        18 = adjust tempo */
  1906. /*        19 = sweep tempo absolute */
  1907. /*        20 = sweep tempo relative */
  1908. /*       32 = restore stereo position */
  1909. /*       33 = set stereo position */
  1910. /*       34 = adjust stereo position */
  1911. /*       35 = sweep stereo position absolute */
  1912. /*       36 = sweep stereo position relative */
  1913. /*        48 = restore volume */
  1914. /*        49 = set volume */
  1915. /*        50 = adjust volume */
  1916. /*        51 = sweep volume absolute */
  1917. /*        52 = sweep volume relative */
  1918. /*       64 = restore release point 1 */
  1919. /*       65 = set release point 1 */
  1920. /*       66 = adjust release point 1 */
  1921. /*       67 = set release point 1 origin */
  1922. /*       68 = sweep release point 1 absolute */
  1923. /*       69 = sweep release point 1 relative */
  1924. /*        80 = restore release point 2 */
  1925. /*        81 = set release point 2 */
  1926. /*        82 = adjust release point 2 */
  1927. /*        83 = set release point 2 origin */
  1928. /*        84 = sweep release point 2 absolute */
  1929. /*        85 = sweep release point 2 relative */
  1930. /*       96 = restore accent 1 */
  1931. /*       97 = set accent 1 */
  1932. /*       98 = adjust accent 1 */
  1933. /*       99 = sweep accent 1 absolute */
  1934. /*       100 = sweep accent 1 relative */
  1935. /*        112 = restore accent 2 */
  1936. /*        113 = set accent 2 */
  1937. /*        114 = adjust accent 2 */
  1938. /*        115 = sweep accent 2 absolute */
  1939. /*        116 = sweep accent 2 relative */
  1940. /*       128 = restore accent 3 */
  1941. /*       129 = set accent 3 */
  1942. /*       130 = adjust accent 3 */
  1943. /*       131 = sweep accent 3 absolute */
  1944. /*       132 = sweep accent 3 relative */
  1945. /*        144 = restore accent 4 */
  1946. /*        145 = set accent 4 */
  1947. /*        146 = adjust accent 4 */
  1948. /*        147 = sweep accent 4 absolute */
  1949. /*        148 = sweep accent 4 relative */
  1950. /*       160 = restore pitch displacement depth */
  1951. /*       161 = set pitch displacement depth */
  1952. /*       162 = adjust pitch displacement depth */
  1953. /*       163 = set pitch displacement depth modulation mode */
  1954. /*       164 = sweep pitch displacement depth absolute */
  1955. /*       165 = sweep pitch displacement depth relative */
  1956. /*        176 = restore pitch displacement rate */
  1957. /*        177 = set pitch displacement rate */
  1958. /*        178 = adjust pitch displacement rate */
  1959. /*        179 = sweep pitch displacement rate absolute */
  1960. /*        180 = sweep pitch displacement rate relative */
  1961. /*       192 = restore pitch displacement start point */
  1962. /*       193 = set pitch displacement start point */
  1963. /*       194 = adjust pitch displacement start point */
  1964. /*       195 = set pitch displacement start point origin */
  1965. /*       196 = sweep pitch displacement start point absolute */
  1966. /*       197 = sweep pitch displacement start point relative */
  1967. /*        208 = restore hurry-up factor */
  1968. /*        209 = set hurry-up factor */
  1969. /*        210 = adjust hurry-up factor */
  1970. /*        211 = sweep hurry-up factor absolute */
  1971. /*        212 = sweep hurry-up factor relative */
  1972. /*       224 = restore detuning */
  1973. /*       225 = set detuning */
  1974. /*       226 = adjust detuning */
  1975. /*       227 = set detuning mode */
  1976. /*       228 = sweep detuning absolute */
  1977. /*       229 = sweep detuning relative */
  1978. /*        240 = restore early/late adjust */
  1979. /*        241 = set early/late adjust */
  1980. /*        242 = adjust early/late adjust */
  1981. /*        243 = sweep early/late adjust absolute */
  1982. /*        244 = sweep early/late adjust relative */
  1983. /*       256 = restore duration adjust */
  1984. /*       257 = set duration adjust */
  1985. /*       258 = adjust duration adjust */
  1986. /*       259 = sweep duration adjust absolute */
  1987. /*       260 = sweep duration adjust relative */
  1988. /*       261 = set duration adjust mode */
  1989. /*        272 = set meter */
  1990. /*        273 = set measure number */
  1991. /*       288 = comment */
  1992. /*        304 = restore surround position */
  1993. /*        305 = set surround position */
  1994. /*        306 = adjust surround position */
  1995. /*        307 = sweep surround position absolute */
  1996. /*        308 = sweep surround position relative */
  1997. /*       320 = set transpose */
  1998. /*       321 = adjust transpose */
  1999. /*       no other values besides these are allowed! */
  2000. /* Format of data for each command (not including the 4-byte opcode word): */
  2001. /* 16 = restore tempo */
  2002. /*   no arguments */
  2003. /* 17 = set tempo */
  2004. /*   4-byte little endian extended integer coded decimal number of beats per minute */
  2005. /*       an extended integer coded decimal is 1000 * the decimal value, with */
  2006. /*       a range of -1999999.999 to 1999999.999 */
  2007. /* 18 = adjust tempo */
  2008. /*   4-byte little endian extended integer coded decimal beats per minute adjust */
  2009. /* 19 = sweep tempo absolute */
  2010. /*   4-byte little endian extended integer coded decimal target beats per minute */
  2011. /*   4-byte little endian extended integer coded decimal number of beats to reach it */
  2012. /* 20 = sweep tempo relative */
  2013. /*   4-byte little endian extended integer coded decimal target beats per minute adjust */
  2014. /*   4-byte little endian extended integer coded decimal number of beats to reach it */
  2015. /* 32 = restore stereo position */
  2016. /*   no arguments */
  2017. /* 33 = set stereo position */
  2018. /*   4-byte little endian large integer coded decimal stereo position value */
  2019. /*       -1 is left, 1 is right, 0 is center */
  2020. /* 34 = adjust stereo position */
  2021. /*   4-byte little endian large integer coded decimal stereo position adjustment */
  2022. /* 35 = sweep stereo position absolute */
  2023. /*   4-byte little endian large integer coded decimal target stereo position */
  2024. /*   4-byte little endian extended integer coded decimal number of beats to reach it */
  2025. /* 36 = sweep stereo position relative */
  2026. /*   4-byte little endian large integer coded decimal target stereo position adjust */
  2027. /*   4-byte little endian extended integer coded decimal number of beats to reach it */
  2028. /* 48 = restore volume */
  2029. /*   no arguments */
  2030. /* 49 = set volume */
  2031. /*   4-byte little endian large integer coded decimal volume level specifier */
  2032. /* 50 = adjust volume */
  2033. /*   4-byte little endian large integer coded decimal volume level adjustment */
  2034. /* 51 = sweep volume absolute */
  2035. /*   4-byte little endian large integer coded decimal target volume level */
  2036. /*   4-byte little endian extended integer coded decimal number of beats to reach it */
  2037. /* 52 = sweep volume relative */
  2038. /*   4-byte little endian large integer coded decimal target volume level adjust */
  2039. /*   4-byte little endian extended integer coded decimal number of beats to reach it */
  2040. /* 64 = restore release point 1 */
  2041. /*   no arguments */
  2042. /* 65 = set release point 1 */
  2043. /*   4-byte little endian large integer coded decimal release point */
  2044. /* 66 = adjust release point 1 */
  2045. /*   4-byte little endian large integer coded decimal release point adjust */
  2046. /* 67 = set release point 1 origin */
  2047. /*   1-byte origin specifier */
  2048. /*       0 = from start */
  2049. /*       1 = from end */
  2050. /* 68 = sweep release point 1 absolute */
  2051. /*   4-byte little endian large integer coded decimal target release point */
  2052. /*   4-byte little endian extended integer coded decimal number of beats to reach it */
  2053. /* 69 = sweep release point 1 relative */
  2054. /*   4-byte little endian large integer coded decimal target release point adjust */
  2055. /*   4-byte little endian extended integer coded decimal number of beats to reach it */
  2056. /* 80 = restore release point 2 */
  2057. /*   no arguments */
  2058. /* 81 = set release point 2 */
  2059. /*   4-byte little endian large integer coded decimal release point */
  2060. /* 82 = adjust release point 2 */
  2061. /*   4-byte little endian large integer coded decimal release point adjust */
  2062. /* 83 = set release point 2 origin */
  2063. /*   1-byte origin specifier */
  2064. /*       0 = from start */
  2065. /*       1 = from end */
  2066. /* 84 = sweep release point 2 absolute */
  2067. /*   4-byte little endian large integer coded decimal target release point */
  2068. /*   4-byte little endian extended integer coded decimal number of beats to reach it */
  2069. /* 85 = sweep release point 2 relative */
  2070. /*   4-byte little endian large integer coded decimal target release point adjust */
  2071. /*   4-byte little endian extended integer coded decimal number of beats to reach it */
  2072. /* 96 = restore accent 1 */
  2073. /*   no arguments */
  2074. /* 97 = set accent 1 */
  2075. /*   4-byte little endian large integer coded decimal accent value */
  2076. /* 98 = adjust accent 1 */
  2077. /*   4-byte little endian large integer coded decimal accent adjust */
  2078. /* 99 = sweep accent 1 absolute */
  2079. /*   4-byte little endian large integer coded decimal target accent */
  2080. /*   4-byte little endian extended integer coded decimal number of beats to reach it */
  2081. /* 100 = sweep accent 1 relative */
  2082. /*   4-byte little endian large integer coded decimal target accent adjust */
  2083. /*   4-byte little endian extended integer coded decimal number of beats to reach it */
  2084. /* 112 = restore accent 2 */
  2085. /*   no arguments */
  2086. /* 113 = set accent 2 */
  2087. /*   4-byte little endian large integer coded decimal accent value */
  2088. /* 114 = adjust accent 2 */
  2089. /*   4-byte little endian large integer coded decimal accent adjust */
  2090. /* 115 = sweep accent 2 absolute */
  2091. /*   4-byte little endian large integer coded decimal target accent */
  2092. /*   4-byte little endian extended integer coded decimal number of beats to reach it */
  2093. /* 116 = sweep accent 2 relative */
  2094. /*   4-byte little endian large integer coded decimal target accent adjust */
  2095. /*   4-byte little endian extended integer coded decimal number of beats to reach it */
  2096. /* 128 = restore accent 3 */
  2097. /*   no arguments */
  2098. /* 129 = set accent 3 */
  2099. /*   4-byte little endian large integer coded decimal accent value */
  2100. /* 130 = adjust accent 3 */
  2101. /*   4-byte little endian large integer coded decimal accent adjust */
  2102. /* 131 = sweep accent 3 absolute */
  2103. /*   4-byte little endian large integer coded decimal target accent */
  2104. /*   4-byte little endian extended integer coded decimal number of beats to reach it */
  2105. /* 132 = sweep accent 3 relative */
  2106. /*   4-byte little endian large integer coded decimal target accent adjust */
  2107. /*   4-byte little endian extended integer coded decimal number of beats to reach it */
  2108. /* 144 = restore accent 4 */
  2109. /*   no arguments */
  2110. /* 145 = set accent 4 */
  2111. /*   4-byte little endian large integer coded decimal accent value */
  2112. /* 146 = adjust accent 4 */
  2113. /*   4-byte little endian large integer coded decimal accent adjust */
  2114. /* 147 = sweep accent 4 absolute */
  2115. /*   4-byte little endian large integer coded decimal target accent */
  2116. /*   4-byte little endian extended integer coded decimal number of beats to reach it */
  2117. /* 148 = sweep accent 4 relative */
  2118. /*   4-byte little endian large integer coded decimal target accent adjust */
  2119. /*   4-byte little endian extended integer coded decimal number of beats to reach it */
  2120. /* 160 = restore pitch displacement depth */
  2121. /*   no arguments */
  2122. /* 161 = set pitch displacement depth */
  2123. /*   4-byte little endian large integer coded decimal pitch disp depth */
  2124. /* 162 = adjust pitch displacement depth */
  2125. /*   4-byte little endian large integer coded decimal pitch disp depth adjust */
  2126. /* 163 = set pitch displacement depth modulation mode */
  2127. /*   1-byte mode flag */
  2128. /*       0 = hertz */
  2129. /*       1 = half steps */
  2130. /* 164 = sweep pitch displacement depth absolute */
  2131. /*   4-byte little endian large integer coded decimal target pitch disp depth */
  2132. /*   4-byte little endian extended integer coded decimal number of beats to reach it */
  2133. /* 165 = sweep pitch displacement depth relative */
  2134. /*   4-byte little endian large integer coded decimal target pitch disp depth adjust */
  2135. /*   4-byte little endian extended integer coded decimal number of beats to reach it */
  2136. /* 176 = restore pitch displacement rate */
  2137. /*   no arguments */
  2138. /* 177 = set pitch displacement rate */
  2139. /*   4-byte little endian large integer coded decimal pitch disp rate */
  2140. /* 178 = adjust pitch displacement rate */
  2141. /*   4-byte little endian large integer coded decimal pitch disp rate adjust */
  2142. /* 179 = sweep pitch displacement rate absolute */
  2143. /*   4-byte little endian large integer coded decimal target pitch disp rate */
  2144. /*   4-byte little endian extended integer coded decimal number of beats to reach it */
  2145. /* 180 = sweep pitch displacement rate relative */
  2146. /*   4-byte little endian large integer coded decimal target pitch disp rate adjust */
  2147. /*   4-byte little endian extended integer coded decimal number of beats to reach it */
  2148. /* 192 = restore pitch displacement start point */
  2149. /*   no arguments */
  2150. /* 193 = set pitch displacement start point */
  2151. /*   4-byte little endian large integer coded decimal pitch disp start point */
  2152. /* 194 = adjust pitch displacement start point */
  2153. /*   4-byte little endian large integer coded decimal pitch disp start point adjust */
  2154. /* 195 = set pitch displacement start point origin */
  2155. /*   1-byte start point origin */
  2156. /*       0 = from start */
  2157. /*       1 = from end */
  2158. /* 196 = sweep pitch displacement start point absolute */
  2159. /*   4-byte little endian large integer coded decimal target pitch disp start point */
  2160. /*   4-byte little endian extended integer coded decimal number of beats to reach it */
  2161. /* 197 = sweep pitch displacement start point relative */
  2162. /*   4-byte little endian large integer coded decimal target pitch disp start adjust */
  2163. /*   4-byte little endian extended integer coded decimal number of beats to reach it */
  2164. /* 208 = restore hurry-up factor */
  2165. /*   no arguments */
  2166. /* 209 = set hurry-up factor */
  2167. /*   4-byte little endian large integer coded decimal hurry-up factor */
  2168. /* 210 = adjust hurry-up factor */
  2169. /*   4-byte little endian large integer coded decimal hurry-up factor adjust */
  2170. /* 211 = sweep hurry-up factor absolute */
  2171. /*   4-byte little endian large integer coded decimal target hurry-up factor */
  2172. /*   4-byte little endian extended integer coded decimal number of beats to reach it */
  2173. /* 212 = sweep hurry-up factor relative */
  2174. /*   4-byte little endian large integer coded decimal target hurry-up factor adjust */
  2175. /*   4-byte little endian extended integer coded decimal number of beats to reach it */
  2176. /* 224 = restore detuning */
  2177. /*   no arguments */
  2178. /* 225 = set detuning */
  2179. /*   4-byte little endian large integer coded decimal detuning */
  2180. /* 226 = adjust detuning */
  2181. /*   4-byte little endian large integer coded decimal detuning adjust */
  2182. /* 227 = set detuning mode */
  2183. /*   1-byte detuning mode specifier */
  2184. /*       0 = hertz */
  2185. /*       1 = half steps */
  2186. /* 228 = sweep detuning absolute */
  2187. /*   4-byte little endian large integer coded decimal target detuning */
  2188. /*   4-byte little endian extended integer coded decimal number of beats to reach it */
  2189. /* 229 = sweep detuning relative */
  2190. /*   4-byte little endian large integer coded decimal target detuning adjust */
  2191. /*   4-byte little endian extended integer coded decimal number of beats to reach it */
  2192. /* 240 = restore early/late adjust */
  2193. /*   no arguments */
  2194. /* 241 = set early/late adjust */
  2195. /*   4-byte little endian large integer coded decimal early/late adjust */
  2196. /* 242 = adjust early/late adjust */
  2197. /*   4-byte little endian large integer coded decimal early/late adjust adjustment */
  2198. /* 243 = sweep early/late adjust absolute */
  2199. /*   4-byte little endian large integer coded decimal target early/late adjust */
  2200. /*   4-byte little endian extended integer coded decimal number of beats to reach it */
  2201. /* 244 = sweep early/late adjust relative */
  2202. /*   4-byte little endian large integer coded decimal target early/late adjust adjust */
  2203. /*   4-byte little endian extended integer coded decimal number of beats to reach it */
  2204. /* 256 = restore duration adjust */
  2205. /*   no arguments */
  2206. /* 257 = set duration adjust */
  2207. /*   4-byte little endian large integer coded decimal duration adjust */
  2208. /* 258 = adjust duration adjust */
  2209. /*   4-byte little endian large integer coded decimal duration adjust adjustment */
  2210. /* 259 = sweep duration adjust absolute */
  2211. /*   4-byte little endian large integer coded decimal target duration adjust */
  2212. /*   4-byte little endian extended integer coded decimal number of beats to reach it */
  2213. /* 260 = sweep duration adjust relative */
  2214. /*   4-byte little endian large integer coded decimal target duration adjust adjust */
  2215. /*   4-byte little endian extended integer coded decimal number of beats to reach it */
  2216. /* 261 = set duration adjust mode */
  2217. /*   1 byte mode flag */
  2218. /*       0 = multiplicative */
  2219. /*       1 = additive */
  2220. /* 272 = set meter */
  2221. /*   4-byte little endian numerator */
  2222. /*   4-byte little endian denominator */
  2223. /* 273 = set measure number */
  2224. /*   4-byte little endian new measure number */
  2225. /* 288 = comment */
  2226. /*   4-byte little endian length of comment text string */
  2227. /*   n-byte comment text string (line feed = 0x0a) */
  2228. /* 304 = restore surround position */
  2229. /*   no arguments */
  2230. /* 305 = set surround position */
  2231. /*   4-byte little endian large integer coded decimal surround position value */
  2232. /*       1 is front, 0 is middle, -1 is rear */
  2233. /* 306 = adjust surround position */
  2234. /*   4-byte little endian large integer coded decimal surround position adjustment */
  2235. /* 307 = sweep surround position absolute */
  2236. /*   4-byte little endian large integer coded decimal target surround position */
  2237. /*   4-byte little endian extended integer coded decimal number of beats to reach it */
  2238. /* 308 = sweep surround position relative */
  2239. /*   4-byte little endian large integer coded decimal target surround position adjust */
  2240. /*   4-byte little endian extended integer coded decimal number of beats to reach it */
  2241. /* 320 = set transpose */
  2242. /*   4-byte signed little endian half-step change (<0 decreases pitch) */
  2243. /* 321 = adjust transpose */
  2244. /*   4-byte signed little endian transpose adjustment */
  2245.  
  2246.  
  2247. /* read a note object in from a file.  this does not handle ties since they */
  2248. /* are done separately. */
  2249. FileLoadingErrors            NoteObjectNewFromFile(NoteObjectRec** ObjectOut,
  2250.                                                 struct BufferedInputRec* Input)
  2251.     {
  2252.         NoteObjectRec*            Note;
  2253.         FileLoadingErrors        Error;
  2254.  
  2255.         CheckPtrExistence(Input);
  2256.  
  2257.         Note = (NoteObjectRec*)AllocPtrCanFail(sizeof(NoteObjectRec),"NoteObjectRec");
  2258.         if (Note == NIL)
  2259.             {
  2260.                 Error = eFileLoadOutOfMemory;
  2261.              FailurePoint1:
  2262.                 return Error;
  2263.             }
  2264.  
  2265.         /*   4-byte unsigned little endian opcode field */
  2266.         /*       for a command, the high bit will be 1 and the remaining bits will */
  2267.         /*       be the opcode.  for a note, the high bit will be 0. */
  2268.         if (!ReadBufferedUnsignedLongLittleEndian(Input,&(Note->Flags)))
  2269.             {
  2270.                 Error = eFileLoadDiskError;
  2271.              FailurePoint2:
  2272.                 ReleasePtr((char*)Note);
  2273.                 goto FailurePoint1;
  2274.             }
  2275.  
  2276.         if ((Note->Flags & eCommandFlag) == 0)
  2277.             {
  2278.                 signed short                SignedShort;
  2279.  
  2280.                 /* it's a note */
  2281.  
  2282.                 /* check opcode flags for validity */
  2283.                 if (
  2284.                         (((Note->Flags & eDurationMask) != e64thNote)
  2285.                         && ((Note->Flags & eDurationMask) != e32ndNote)
  2286.                         && ((Note->Flags & eDurationMask) != e16thNote)
  2287.                         && ((Note->Flags & eDurationMask) != e8thNote)
  2288.                         && ((Note->Flags & eDurationMask) != e4thNote)
  2289.                         && ((Note->Flags & eDurationMask) != e2ndNote)
  2290.                         && ((Note->Flags & eDurationMask) != eWholeNote)
  2291.                         && ((Note->Flags & eDurationMask) != eDoubleNote)
  2292.                         && ((Note->Flags & eDurationMask) != eQuadNote))
  2293.                     ||
  2294.                         (((Note->Flags & eFlatModifier) != 0)
  2295.                         && ((Note->Flags & eSharpModifier) != 0))
  2296.                     ||
  2297.                         (((Note->Flags & eRelease1OriginMask) != eRelease1FromDefault)
  2298.                         && ((Note->Flags & eRelease1OriginMask) != eRelease1FromStart)
  2299.                         && ((Note->Flags & eRelease1OriginMask) != eRelease1FromEnd))
  2300.                     ||
  2301.                         (((Note->Flags & eRelease2OriginMask) != eRelease2FromDefault)
  2302.                         && ((Note->Flags & eRelease2OriginMask) != eRelease2FromStart)
  2303.                         && ((Note->Flags & eRelease2OriginMask) != eRelease2FromEnd))
  2304.                     ||
  2305.                         (((Note->Flags & ePitchDisplacementStartOriginMask)
  2306.                             != ePitchDisplacementStartFromDefault)
  2307.                         && ((Note->Flags & ePitchDisplacementStartOriginMask)
  2308.                             != ePitchDisplacementStartFromStart)
  2309.                         && ((Note->Flags & ePitchDisplacementStartOriginMask)
  2310.                             != ePitchDisplacementStartFromEnd))
  2311.                     ||
  2312.                         (((Note->Flags & ePitchDisplacementDepthModeMask)
  2313.                             != ePitchDisplacementDepthModeDefault)
  2314.                         && ((Note->Flags & ePitchDisplacementDepthModeMask)
  2315.                             != ePitchDisplacementDepthModeHalfSteps)
  2316.                         && ((Note->Flags & ePitchDisplacementDepthModeMask)
  2317.                             != ePitchDisplacementDepthModeHertz))
  2318.                     ||
  2319.                         (((Note->Flags & eDetuningModeMask) != eDetuningModeDefault)
  2320.                         && ((Note->Flags & eDetuningModeMask) != eDetuningModeHalfSteps)
  2321.                         && ((Note->Flags & eDetuningModeMask) != eDetuningModeHertz))
  2322.                     ||
  2323.                         (((Note->Flags & eDurationAdjustMask) != eDurationAdjustDefault)
  2324.                         && ((Note->Flags & eDurationAdjustMask) != eDurationAdjustAdditive)
  2325.                         && ((Note->Flags & eDurationAdjustMask) != eDurationAdjustMultiplicative)))
  2326.                     {
  2327.                      FailurePointNoteBadFormat:
  2328.                         Error = eFileLoadBadFormat;
  2329.                         goto FailurePoint2;
  2330.                     }
  2331.  
  2332.                 /*   2-byte signed little endian pitch index */
  2333.                 /*       should be a value in the range 0..383.  Middle C (261.6 Hertz) = 192 */
  2334.                 if (!ReadBufferedSignedShortLittleEndian(Input,&SignedShort))
  2335.                     {
  2336.                      FailurePointNoteDiskError:
  2337.                         Error = eFileLoadDiskError;
  2338.                         goto FailurePoint2;
  2339.                     }
  2340.                 if ((SignedShort < 0) || (SignedShort >= NUMNOTES))
  2341.                     {
  2342.                         goto FailurePointNoteBadFormat;
  2343.                     }
  2344.                 Note->a.Note.Pitch = SignedShort;
  2345.  
  2346.                 /*   2-byte little endian small integer coded decimal portamento duration. */
  2347.                 /*       this determines how long a portamento will last, in fractions of a quarter */
  2348.                 /*       note.  it only has effect if the note is the target of a tie.  a value of */
  2349.                 /*       0 means instantaneous, i.e. no portamento. */
  2350.                 /*       A small integer coded decimal is the decimal * 1000 with a range */
  2351.                 /*       of -29.999 to 29.999 */
  2352.                 if (!ReadBufferedSignedShortLittleEndian(Input,&SignedShort))
  2353.                     {
  2354.                         goto FailurePointNoteDiskError;
  2355.                     }
  2356.                 Note->a.Note.PortamentoDuration = SignedShort;
  2357.  
  2358.                 /*   2-byte little endian small integer coded decimal early/late adjustment */
  2359.                 /*       this determines the displacement in time of the occurrence of the note */
  2360.                 /*       in frations of a quarter note. */
  2361.                 if (!ReadBufferedSignedShortLittleEndian(Input,&SignedShort))
  2362.                     {
  2363.                         goto FailurePointNoteDiskError;
  2364.                     }
  2365.                 Note->a.Note.EarlyLateAdjust = SignedShort;
  2366.  
  2367.                 /*   2-byte little endian small integer coded decimal duration adjustment */
  2368.                 /*       this value changes the duration of the note by being added to the */
  2369.                 /*       duration or being multiplied by the duration. */
  2370.                 if (!ReadBufferedSignedShortLittleEndian(Input,&SignedShort))
  2371.                     {
  2372.                         goto FailurePointNoteDiskError;
  2373.                     }
  2374.                 Note->a.Note.DurationAdjust = SignedShort;
  2375.  
  2376.                 Note->a.Note.Tie = NIL;
  2377.  
  2378.                 /*   2-byte little endian small integer coded decimal release point 1 location */
  2379.                 /*       this determines when the release of the first sustain/loop will occur */
  2380.                 /*       in fractions of the current note's duration.  it is relative to the origin */
  2381.                 /*       as determined by the opcode field. */
  2382.                 if (!ReadBufferedSignedShortLittleEndian(Input,&SignedShort))
  2383.                     {
  2384.                         goto FailurePointNoteDiskError;
  2385.                     }
  2386.                 Note->a.Note.ReleasePoint1 = SignedShort;
  2387.  
  2388.                 /*   2-byte little endian small integer coded decimal release point 2 location */
  2389.                 /*       this determines when the release of the second sustain/loop will occur. */
  2390.                 if (!ReadBufferedSignedShortLittleEndian(Input,&SignedShort))
  2391.                     {
  2392.                         goto FailurePointNoteDiskError;
  2393.                     }
  2394.                 Note->a.Note.ReleasePoint2 = SignedShort;
  2395.  
  2396.                 /*   2-byte little endian small integer coded decimal overall loudness adjustment */
  2397.                 /*       this factor scales the total volume output of the oscillators for this */
  2398.                 /*       particular note.  It is multiplied, so a value of 1 makes no change in */
  2399.                 /*       loudness. */
  2400.                 if (!ReadBufferedSignedShortLittleEndian(Input,&SignedShort))
  2401.                     {
  2402.                         goto FailurePointNoteDiskError;
  2403.                     }
  2404.                 Note->a.Note.OverallLoudnessAdjustment = SignedShort;
  2405.  
  2406.                 /*   2-byte little endian small integer coded decimal stereo position adjustment. */
  2407.                 /*       this value adjusts where the sound will be located in stereo.  -1 is */
  2408.                 /*       the far left, 1 is the far right, and 0 is center. */
  2409.                 if (!ReadBufferedSignedShortLittleEndian(Input,&SignedShort))
  2410.                     {
  2411.                         goto FailurePointNoteDiskError;
  2412.                     }
  2413.                 Note->a.Note.StereoPositionAdjustment = SignedShort;
  2414.  
  2415.                 /*   2-byte little endian small integer coded decimal surround position adjustment. */
  2416.                 /*       this value adjusts where the sound will be located in surround. */
  2417.                 /*       1 is front and -1 is rear. */
  2418.                 if (!ReadBufferedSignedShortLittleEndian(Input,&SignedShort))
  2419.                     {
  2420.                         goto FailurePointNoteDiskError;
  2421.                     }
  2422.                 Note->a.Note.SurroundPositionAdjustment = SignedShort;
  2423.  
  2424.                 /*   2-byte little endian small integer coded decimal accent 1 value */
  2425.                 if (!ReadBufferedSignedShortLittleEndian(Input,&SignedShort))
  2426.                     {
  2427.                         goto FailurePointNoteDiskError;
  2428.                     }
  2429.                 Note->a.Note.Accent1 = SignedShort;
  2430.  
  2431.                 /*   2-byte little endian small integer coded decimal accent 2 value */
  2432.                 if (!ReadBufferedSignedShortLittleEndian(Input,&SignedShort))
  2433.                     {
  2434.                         goto FailurePointNoteDiskError;
  2435.                     }
  2436.                 Note->a.Note.Accent2 = SignedShort;
  2437.  
  2438.                 /*   2-byte little endian small integer coded decimal accent 3 value */
  2439.                 if (!ReadBufferedSignedShortLittleEndian(Input,&SignedShort))
  2440.                     {
  2441.                         goto FailurePointNoteDiskError;
  2442.                     }
  2443.                 Note->a.Note.Accent3 = SignedShort;
  2444.  
  2445.                 /*   2-byte little endian small integer coded decimal accent 4 value */
  2446.                 if (!ReadBufferedSignedShortLittleEndian(Input,&SignedShort))
  2447.                     {
  2448.                         goto FailurePointNoteDiskError;
  2449.                     }
  2450.                 Note->a.Note.Accent4 = SignedShort;
  2451.  
  2452.                 /*   2-byte little endian fake pitch value */
  2453.                 /*       this value has a range of -1..383.  If it is not -1, then it will be used */
  2454.                 /*       to determine which sample a multisampled oscillator will use.  If it is -1 */
  2455.                 /*       then the actual pitch will be used to select a sample. */
  2456.                 if (!ReadBufferedSignedShortLittleEndian(Input,&SignedShort))
  2457.                     {
  2458.                         goto FailurePointNoteDiskError;
  2459.                     }
  2460.                 if ((SignedShort < -1) || (SignedShort >= NUMNOTES))
  2461.                     {
  2462.                         goto FailurePointNoteBadFormat;
  2463.                     }
  2464.                 Note->a.Note.MultisamplePitchAsIf = SignedShort;
  2465.  
  2466.                 /*   2-byte little endian small integer coded decimal pitch disp depth adjustment */
  2467.                 /*       this adjusts the maximum amplitude of the pitch displacement depth */
  2468.                 /*       oscillator (vibrato).  The value has units of either half steps or hertz */
  2469.                 /*       depending on the setting in the opcode word. */
  2470.                 if (!ReadBufferedSignedShortLittleEndian(Input,&SignedShort))
  2471.                     {
  2472.                         goto FailurePointNoteDiskError;
  2473.                     }
  2474.                 Note->a.Note.PitchDisplacementDepthAdjustment = SignedShort;
  2475.  
  2476.                 /*   2-byte little endian small integer coded decimal pitch displ rate adjustment */
  2477.                 /*       this adjusts the maximum amplitude of the pitch displacement rate */
  2478.                 /*       oscillator. the units are periods per second. */
  2479.                 if (!ReadBufferedSignedShortLittleEndian(Input,&SignedShort))
  2480.                     {
  2481.                         goto FailurePointNoteDiskError;
  2482.                     }
  2483.                 Note->a.Note.PitchDisplacementRateAdjustment = SignedShort;
  2484.  
  2485.                 /*   2-byte little endian small integer coded decimal pitch displ start point adjust */
  2486.                 /*       this value adjusts when the pitch displacement envelopes start.  the */
  2487.                 /*       location is from start or end of note, depending on the opcode settings, and */
  2488.                 /*       is in fractions of the current note's duration. */
  2489.                 if (!ReadBufferedSignedShortLittleEndian(Input,&SignedShort))
  2490.                     {
  2491.                         goto FailurePointNoteDiskError;
  2492.                     }
  2493.                 Note->a.Note.PitchDisplacementStartPoint = SignedShort;
  2494.  
  2495.                 /*   2-byte little endian small integer coded decimal hurry-up factor */
  2496.                 /*       this factor scales the total speed at which all envelopes change.  this is */
  2497.                 /*       multiplicative, so a value of 1 makes no change, and smaller values make */
  2498.                 /*       transitions go faster. */
  2499.                 if (!ReadBufferedSignedShortLittleEndian(Input,&SignedShort))
  2500.                     {
  2501.                         goto FailurePointNoteDiskError;
  2502.                     }
  2503.                 Note->a.Note.HurryUpFactor = SignedShort;
  2504.  
  2505.                 /*   2-byte little endian small integer coded decimal detuning value */
  2506.                 /*       this value is added to the pitch of the note to detune.  its units are */
  2507.                 /*       either hertz or half steps depending on the opcode word. */
  2508.                 if (!ReadBufferedSignedShortLittleEndian(Input,&SignedShort))
  2509.                     {
  2510.                         goto FailurePointNoteDiskError;
  2511.                     }
  2512.                 Note->a.Note.Detuning = SignedShort;
  2513.             }
  2514.          else
  2515.             {
  2516.                 signed long                    SignedLong;
  2517.                 unsigned char                UnsignedChar;
  2518.  
  2519.                 /* it's a command; clear out the operand fields to begin with */
  2520.                 Note->a.Command.StringArgument = AllocPtrCanFail(0,
  2521.                     "NoteObjectRec:  command string argument");
  2522.                 if (Note->a.Command.StringArgument == NIL)
  2523.                     {
  2524.                         Error = eFileLoadOutOfMemory;
  2525.                         goto FailurePoint2;
  2526.                     }
  2527.                 Note->a.Command.Argument1 = 0;
  2528.                 Note->a.Command.Argument2 = 0;
  2529.                 Note->a.Command.Argument3 = 0;
  2530.  
  2531.                 /* read in operands */
  2532.                 switch (Note->Flags & ~eCommandFlag)
  2533.                     {
  2534.                         default:
  2535.                          FailurePoint3:
  2536.                             ReleasePtr(Note->a.Command.StringArgument);
  2537.                             Error = eFileLoadBadFormat;
  2538.                             goto FailurePoint2;
  2539.  
  2540.                         /*   no arguments */
  2541.                         case 16: /* 16 = restore tempo */
  2542.                         case 32: /* 32 = restore stereo position */
  2543.                         case 48: /* 48 = restore volume */
  2544.                         case 64: /* 64 = restore release point 1 */
  2545.                         case 80: /* 80 = restore release point 2 */
  2546.                         case 96: /* 96 = restore accent 1 */
  2547.                         case 112: /* 112 = restore accent 2 */
  2548.                         case 128: /* 128 = restore accent 3 */
  2549.                         case 144: /* 144 = restore accent 4 */
  2550.                         case 160: /* 160 = restore pitch displacement depth */
  2551.                         case 176: /* 176 = restore pitch displacement rate */
  2552.                         case 192: /* 192 = restore pitch displacement start point */
  2553.                         case 208: /* 208 = restore hurry-up factor */
  2554.                         case 224: /* 224 = restore detuning */
  2555.                         case 240: /* 240 = restore early/late adjust */
  2556.                         case 256: /* 256 = restore duration adjust */
  2557.                         case 304: /* 304 = restore surround position */
  2558.                             break;
  2559.  
  2560.                         /*   4-byte little endian large/extended integer coded decimal */
  2561.                         case 17: /* 17 = set tempo */
  2562.                         case 18: /* 18 = adjust tempo */
  2563.                         case 33: /* 33 = set stereo position */
  2564.                         case 34: /* 34 = adjust stereo position */
  2565.                         case 49: /* 49 = set volume */
  2566.                         case 50: /* 50 = adjust volume */
  2567.                         case 65: /* 65 = set release point 1 */
  2568.                         case 66: /* 66 = adjust release point 1 */
  2569.                         case 81: /* 81 = set release point 2 */
  2570.                         case 82: /* 82 = adjust release point 2 */
  2571.                         case 97: /* 97 = set accent 1 */
  2572.                         case 98: /* 98 = adjust accent 1 */
  2573.                         case 113: /* 113 = set accent 2 */
  2574.                         case 114: /* 114 = adjust accent 2 */
  2575.                         case 129: /* 129 = set accent 3 */
  2576.                         case 130: /* 130 = adjust accent 3 */
  2577.                         case 145: /* 145 = set accent 4 */
  2578.                         case 146: /* 146 = adjust accent 4 */
  2579.                         case 161: /* 161 = set pitch displacement depth */
  2580.                         case 162: /* 162 = adjust pitch displacement depth */
  2581.                         case 177: /* 177 = set pitch displacement rate */
  2582.                         case 178: /* 178 = adjust pitch displacement rate */
  2583.                         case 193: /* 193 = set pitch displacement start point */
  2584.                         case 194: /* 194 = adjust pitch displacement start point */
  2585.                         case 209: /* 209 = set hurry-up factor */
  2586.                         case 210: /* 210 = adjust hurry-up factor */
  2587.                         case 225: /* 225 = set detuning */
  2588.                         case 226: /* 226 = adjust detuning */
  2589.                         case 241: /* 241 = set early/late adjust */
  2590.                         case 242: /* 242 = adjust early/late adjust */
  2591.                         case 257: /* 257 = set duration adjust */
  2592.                         case 258: /* 258 = adjust duration adjust */
  2593.                         case 273: /* 273 = set measure number */
  2594.                         case 305: /* 305 = set surround position */
  2595.                         case 306: /* 306 = adjust surround position */
  2596.                         case 320: /* 320 = set transpose */
  2597.                         case 321: /* 321 = adjust transpose */
  2598.                             if (!ReadBufferedSignedLongLittleEndian(Input,&SignedLong))
  2599.                                 {
  2600.                                     Error = eFileLoadDiskError;
  2601.                                     goto FailurePoint3;
  2602.                                 }
  2603.                             Note->a.Command.Argument1 = SignedLong;
  2604.                             break;
  2605.  
  2606.                         /*   4-byte little endian large/extended integer coded decimal */
  2607.                         /*   4-byte little endian large/extended integer coded decimal */
  2608.                         case 19: /* 19 = sweep tempo absolute */
  2609.                         case 20: /* 20 = sweep tempo relative */
  2610.                         case 35: /* 35 = sweep stereo position absolute */
  2611.                         case 36: /* 36 = sweep stereo position relative */
  2612.                         case 51: /* 51 = sweep volume absolute */
  2613.                         case 52: /* 52 = sweep volume relative */
  2614.                         case 68: /* 68 = sweep release point 1 absolute */
  2615.                         case 69: /* 69 = sweep release point 1 relative */
  2616.                         case 84: /* 84 = sweep release point 2 absolute */
  2617.                         case 85: /* 85 = sweep release point 2 relative */
  2618.                         case 99: /* 99 = sweep accent 1 absolute */
  2619.                         case 100: /* 100 = sweep accent 1 relative */
  2620.                         case 115: /* 115 = sweep accent 2 absolute */
  2621.                         case 116: /* 116 = sweep accent 2 relative */
  2622.                         case 131: /* 131 = sweep accent 3 absolute */
  2623.                         case 132: /* 132 = sweep accent 3 relative */
  2624.                         case 147: /* 147 = sweep accent 4 absolute */
  2625.                         case 148: /* 148 = sweep accent 4 relative */
  2626.                         case 164: /* 164 = sweep pitch displacement depth absolute */
  2627.                         case 165: /* 165 = sweep pitch displacement depth relative */
  2628.                         case 179: /* 179 = sweep pitch displacement rate absolute */
  2629.                         case 180: /* 180 = sweep pitch displacement rate relative */
  2630.                         case 196: /* 196 = sweep pitch displacement start point absolute */
  2631.                         case 197: /* 197 = sweep pitch displacement start point relative */
  2632.                         case 211: /* 211 = sweep hurry-up factor absolute */
  2633.                         case 212: /* 212 = sweep hurry-up factor relative */
  2634.                         case 228: /* 228 = sweep detuning absolute */
  2635.                         case 229: /* 229 = sweep detuning relative */
  2636.                         case 243: /* 243 = sweep early/late adjust absolute */
  2637.                         case 244: /* 244 = sweep early/late adjust relative */
  2638.                         case 259: /* 259 = sweep duration adjust absolute */
  2639.                         case 260: /* 260 = sweep duration adjust relative */
  2640.                         case 272: /* 272 = set meter */
  2641.                         case 307: /* 307 = sweep surround position absolute */
  2642.                         case 308: /* 308 = sweep surround position relative */
  2643.                             if (!ReadBufferedSignedLongLittleEndian(Input,&SignedLong))
  2644.                                 {
  2645.                                     Error = eFileLoadDiskError;
  2646.                                     goto FailurePoint3;
  2647.                                 }
  2648.                             Note->a.Command.Argument1 = SignedLong;
  2649.                             if (!ReadBufferedSignedLongLittleEndian(Input,&SignedLong))
  2650.                                 {
  2651.                                     Error = eFileLoadDiskError;
  2652.                                     goto FailurePoint3;
  2653.                                 }
  2654.                             Note->a.Command.Argument2 = SignedLong;
  2655.                             break;
  2656.  
  2657.                         /*   1-byte origin specifier */
  2658.                         /*       0 = -1 */
  2659.                         /*       1 = 0 */
  2660.                         case 67: /* 67 = set release point 1 origin */
  2661.                         case 83: /* 83 = set release point 2 origin */
  2662.                         case 163: /* 163 = set pitch displacement depth modulation mode */
  2663.                         case 195: /* 195 = set pitch displacement start point origin */
  2664.                         case 227: /* 227 = set detuning mode */
  2665.                         case 261: /* 261 = set duration adjust mode */
  2666.                             if (!ReadBufferedUnsignedChar(Input,&UnsignedChar))
  2667.                                 {
  2668.                                     Error = eFileLoadDiskError;
  2669.                                     goto FailurePoint3;
  2670.                                 }
  2671.                             if (UnsignedChar == 0)
  2672.                                 {
  2673.                                     Note->a.Command.Argument1 = -1;
  2674.                                 }
  2675.                             else if (UnsignedChar == 1)
  2676.                                 {
  2677.                                     Note->a.Command.Argument1 = 0;
  2678.                                 }
  2679.                             else
  2680.                                 {
  2681.                                     Error = eFileLoadBadFormat;
  2682.                                     goto FailurePoint3;
  2683.                                 }
  2684.                             break;
  2685.  
  2686.                         /*   4-byte little endian length of comment text string */
  2687.                         /*   n-byte comment text string (line feed = 0x0a) */
  2688.                         case 288: /* 288 = comment */
  2689.                             if (!ReadBufferedSignedLongLittleEndian(Input,&SignedLong))
  2690.                                 {
  2691.                                     Error = eFileLoadDiskError;
  2692.                                     goto FailurePoint3;
  2693.                                 }
  2694.                             if (SignedLong < 0)
  2695.                                 {
  2696.                                     Error = eFileLoadBadFormat;
  2697.                                     goto FailurePoint3;
  2698.                                 }
  2699.                             {
  2700.                                 char*                            TempString;
  2701.  
  2702.                                 TempString = AllocPtrCanFail(SignedLong,"NoteObjectRec:  command string argument");
  2703.                                 if (TempString == NIL)
  2704.                                     {
  2705.                                         Error = eFileLoadOutOfMemory;
  2706.                                         goto FailurePoint3;
  2707.                                     }
  2708.                                 ReleasePtr(Note->a.Command.StringArgument);
  2709.                                 Note->a.Command.StringArgument = TempString;
  2710.                             }
  2711.                             if (!ReadBufferedInput(Input,SignedLong,Note->a.Command.StringArgument))
  2712.                                 {
  2713.                                     Error = eFileLoadDiskError;
  2714.                                     goto FailurePoint3;
  2715.                                 }
  2716.                             break;
  2717.                     }
  2718.  
  2719.                 /* convert file format opcode to internal enumeration value */
  2720.                 switch (Note->Flags & ~eCommandFlag)
  2721.                     {
  2722.                         default:
  2723.                             EXECUTE(PRERR(ForceAbort,
  2724.                                 "NoteObjectNewFromFile:  command opcode filter failure"));
  2725.                             break;
  2726.                         case 16: /* 16 = restore tempo */
  2727.                             Note->Flags = eCmdRestoreTempo;
  2728.                             break;
  2729.                         case 17: /* 17 = set tempo */
  2730.                             Note->Flags = eCmdSetTempo;
  2731.                             break;
  2732.                         case 18: /* 18 = adjust tempo */
  2733.                             Note->Flags = eCmdIncTempo;
  2734.                             break;
  2735.                         case 19: /* 19 = sweep tempo absolute */
  2736.                             Note->Flags = eCmdSweepTempoAbs;
  2737.                             break;
  2738.                         case 20: /* 20 = sweep tempo relative */
  2739.                             Note->Flags = eCmdSweepTempoRel;
  2740.                             break;
  2741.                         case 32: /* 32 = restore stereo position */
  2742.                             Note->Flags = eCmdRestoreStereoPosition;
  2743.                             break;
  2744.                         case 33: /* 33 = set stereo position */
  2745.                             Note->Flags = eCmdSetStereoPosition;
  2746.                             break;
  2747.                         case 34: /* 34 = adjust stereo position */
  2748.                             Note->Flags = eCmdIncStereoPosition;
  2749.                             break;
  2750.                         case 35: /* 35 = sweep stereo position absolute */
  2751.                             Note->Flags = eCmdSweepStereoAbs;
  2752.                             break;
  2753.                         case 36: /* 36 = sweep stereo position relative */
  2754.                             Note->Flags = eCmdSweepStereoRel;
  2755.                             break;
  2756.                         case 48: /* 48 = restore volume */
  2757.                             Note->Flags = eCmdRestoreVolume;
  2758.                             break;
  2759.                         case 49: /* 49 = set volume */
  2760.                             Note->Flags = eCmdSetVolume;
  2761.                             break;
  2762.                         case 50: /* 50 = adjust volume */
  2763.                             Note->Flags = eCmdIncVolume;
  2764.                             break;
  2765.                         case 51: /* 51 = sweep volume absolute */
  2766.                             Note->Flags = eCmdSweepVolumeAbs;
  2767.                             break;
  2768.                         case 52: /* 52 = sweep volume relative */
  2769.                             Note->Flags = eCmdSweepVolumeRel;
  2770.                             break;
  2771.                         case 64: /* 64 = restore release point 1 */
  2772.                             Note->Flags = eCmdRestoreReleasePoint1;
  2773.                             break;
  2774.                         case 65: /* 65 = set release point 1 */
  2775.                             Note->Flags = eCmdSetReleasePoint1;
  2776.                             break;
  2777.                         case 66: /* 66 = adjust release point 1 */
  2778.                             Note->Flags = eCmdIncReleasePoint1;
  2779.                             break;
  2780.                         case 67: /* 67 = set release point 1 origin */
  2781.                             Note->Flags = eCmdReleasePointOrigin1;
  2782.                             break;
  2783.                         case 68: /* 68 = sweep release point 1 absolute */
  2784.                             Note->Flags = eCmdSweepReleaseAbs1;
  2785.                             break;
  2786.                         case 69: /* 69 = sweep release point 1 relative */
  2787.                             Note->Flags = eCmdSweepReleaseRel1;
  2788.                             break;
  2789.                         case 80: /* 80 = restore release point 2 */
  2790.                             Note->Flags = eCmdRestoreReleasePoint2;
  2791.                             break;
  2792.                         case 81: /* 81 = set release point 2 */
  2793.                             Note->Flags = eCmdSetReleasePoint2;
  2794.                             break;
  2795.                         case 82: /* 82 = adjust release point 2 */
  2796.                             Note->Flags = eCmdIncReleasePoint2;
  2797.                             break;
  2798.                         case 83: /* 83 = set release point 2 origin */
  2799.                             Note->Flags = eCmdReleasePointOrigin2;
  2800.                             break;
  2801.                         case 84: /* 84 = sweep release point 2 absolute */
  2802.                             Note->Flags = eCmdSweepReleaseAbs2;
  2803.                             break;
  2804.                         case 85: /* 85 = sweep release point 2 relative */
  2805.                             Note->Flags = eCmdSweepReleaseRel2;
  2806.                             break;
  2807.                         case 96: /* 96 = restore accent 1 */
  2808.                             Note->Flags = eCmdRestoreAccent1;
  2809.                             break;
  2810.                         case 97: /* 97 = set accent 1 */
  2811.                             Note->Flags = eCmdSetAccent1;
  2812.                             break;
  2813.                         case 98: /* 98 = adjust accent 1 */
  2814.                             Note->Flags = eCmdIncAccent1;
  2815.                             break;
  2816.                         case 99: /* 99 = sweep accent 1 absolute */
  2817.                             Note->Flags = eCmdSweepAccentAbs1;
  2818.                             break;
  2819.                         case 100: /* 100 = sweep accent 1 relative */
  2820.                             Note->Flags = eCmdSweepAccentRel1;
  2821.                             break;
  2822.                         case 112: /* 112 = restore accent 2 */
  2823.                             Note->Flags = eCmdRestoreAccent2;
  2824.                             break;
  2825.                         case 113: /* 113 = set accent 2 */
  2826.                             Note->Flags = eCmdSetAccent2;
  2827.                             break;
  2828.                         case 114: /* 114 = adjust accent 2 */
  2829.                             Note->Flags = eCmdIncAccent2;
  2830.                             break;
  2831.                         case 115: /* 115 = sweep accent 2 absolute */
  2832.                             Note->Flags = eCmdSweepAccentAbs2;
  2833.                             break;
  2834.                         case 116: /* 116 = sweep accent 2 relative */
  2835.                             Note->Flags = eCmdSweepAccentRel2;
  2836.                             break;
  2837.                         case 128: /* 128 = restore accent 3 */
  2838.                             Note->Flags = eCmdRestoreAccent3;
  2839.                             break;
  2840.                         case 129: /* 129 = set accent 3 */
  2841.                             Note->Flags = eCmdSetAccent3;
  2842.                             break;
  2843.                         case 130: /* 130 = adjust accent 3 */
  2844.                             Note->Flags = eCmdIncAccent3;
  2845.                             break;
  2846.                         case 131: /* 131 = sweep accent 3 absolute */
  2847.                             Note->Flags = eCmdSweepAccentAbs3;
  2848.                             break;
  2849.                         case 132: /* 132 = sweep accent 3 relative */
  2850.                             Note->Flags = eCmdSweepAccentRel3;
  2851.                             break;
  2852.                         case 144: /* 144 = restore accent 4 */
  2853.                             Note->Flags = eCmdRestoreAccent4;
  2854.                             break;
  2855.                         case 145: /* 145 = set accent 4 */
  2856.                             Note->Flags = eCmdSetAccent4;
  2857.                             break;
  2858.                         case 146: /* 146 = adjust accent 4 */
  2859.                             Note->Flags = eCmdIncAccent4;
  2860.                             break;
  2861.                         case 147: /* 147 = sweep accent 4 absolute */
  2862.                             Note->Flags = eCmdSweepAccentAbs4;
  2863.                             break;
  2864.                         case 148: /* 148 = sweep accent 4 relative */
  2865.                             Note->Flags = eCmdSweepAccentRel4;
  2866.                             break;
  2867.                         case 160: /* 160 = restore pitch displacement depth */
  2868.                             Note->Flags = eCmdRestorePitchDispDepth;
  2869.                             break;
  2870.                         case 161: /* 161 = set pitch displacement depth */
  2871.                             Note->Flags = eCmdSetPitchDispDepth;
  2872.                             break;
  2873.                         case 162: /* 162 = adjust pitch displacement depth */
  2874.                             Note->Flags = eCmdIncPitchDispDepth;
  2875.                             break;
  2876.                         case 163: /* 163 = set pitch displacement depth modulation mode */
  2877.                             Note->Flags = eCmdPitchDispDepthMode;
  2878.                             break;
  2879.                         case 164: /* 164 = sweep pitch displacement depth absolute */
  2880.                             Note->Flags = eCmdSweepPitchDispDepthAbs;
  2881.                             break;
  2882.                         case 165: /* 165 = sweep pitch displacement depth relative */
  2883.                             Note->Flags = eCmdSweepPitchDispDepthRel;
  2884.                             break;
  2885.                         case 176: /* 176 = restore pitch displacement rate */
  2886.                             Note->Flags = eCmdRestorePitchDispRate;
  2887.                             break;
  2888.                         case 177: /* 177 = set pitch displacement rate */
  2889.                             Note->Flags = eCmdSetPitchDispRate;
  2890.                             break;
  2891.                         case 178: /* 178 = adjust pitch displacement rate */
  2892.                             Note->Flags = eCmdIncPitchDispRate;
  2893.                             break;
  2894.                         case 179: /* 179 = sweep pitch displacement rate absolute */
  2895.                             Note->Flags = eCmdSweepPitchDispRateAbs;
  2896.                             break;
  2897.                         case 180: /* 180 = sweep pitch displacement rate relative */
  2898.                             Note->Flags = eCmdSweepPitchDispRateRel;
  2899.                             break;
  2900.                         case 192: /* 192 = restore pitch displacement start point */
  2901.                             Note->Flags = eCmdRestorePitchDispStart;
  2902.                             break;
  2903.                         case 193: /* 193 = set pitch displacement start point */
  2904.                             Note->Flags = eCmdSetPitchDispStart;
  2905.                             break;
  2906.                         case 194: /* 194 = adjust pitch displacement start point */
  2907.                             Note->Flags = eCmdIncPitchDispStart;
  2908.                             break;
  2909.                         case 195: /* 195 = set pitch displacement start point origin */
  2910.                             Note->Flags = eCmdPitchDispStartOrigin;
  2911.                             break;
  2912.                         case 196: /* 196 = sweep pitch displacement start point absolute */
  2913.                             Note->Flags = eCmdSweepPitchDispStartAbs;
  2914.                             break;
  2915.                         case 197: /* 197 = sweep pitch displacement start point relative */
  2916.                             Note->Flags = eCmdSweepPitchDispStartRel;
  2917.                             break;
  2918.                         case 208: /* 208 = restore hurry-up factor */
  2919.                             Note->Flags = eCmdRestoreHurryUp;
  2920.                             break;
  2921.                         case 209: /* 209 = set hurry-up factor */
  2922.                             Note->Flags = eCmdSetHurryUp;
  2923.                             break;
  2924.                         case 210: /* 210 = adjust hurry-up factor */
  2925.                             Note->Flags = eCmdIncHurryUp;
  2926.                             break;
  2927.                         case 211: /* 211 = sweep hurry-up factor absolute */
  2928.                             Note->Flags = eCmdSweepHurryUpAbs;
  2929.                             break;
  2930.                         case 212: /* 212 = sweep hurry-up factor relative */
  2931.                             Note->Flags = eCmdSweepHurryUpRel;
  2932.                             break;
  2933.                         case 224: /* 224 = restore detuning */
  2934.                             Note->Flags = eCmdRestoreDetune;
  2935.                             break;
  2936.                         case 225: /* 225 = set detuning */
  2937.                             Note->Flags = eCmdSetDetune;
  2938.                             break;
  2939.                         case 226: /* 226 = adjust detuning */
  2940.                             Note->Flags = eCmdIncDetune;
  2941.                             break;
  2942.                         case 227: /* 227 = set detuning mode */
  2943.                             Note->Flags = eCmdDetuneMode;
  2944.                             break;
  2945.                         case 228: /* 228 = sweep detuning absolute */
  2946.                             Note->Flags = eCmdSweepDetuneAbs;
  2947.                             break;
  2948.                         case 229: /* 229 = sweep detuning relative */
  2949.                             Note->Flags = eCmdSweepDetuneRel;
  2950.                             break;
  2951.                         case 240: /* 240 = restore early/late adjust */
  2952.                             Note->Flags = eCmdRestoreEarlyLateAdjust;
  2953.                             break;
  2954.                         case 241: /* 241 = set early/late adjust */
  2955.                             Note->Flags = eCmdSetEarlyLateAdjust;
  2956.                             break;
  2957.                         case 242: /* 242 = adjust early/late adjust */
  2958.                             Note->Flags = eCmdIncEarlyLateAdjust;
  2959.                             break;
  2960.                         case 243: /* 243 = sweep early/late adjust absolute */
  2961.                             Note->Flags = eCmdSweepEarlyLateAbs;
  2962.                             break;
  2963.                         case 244: /* 244 = sweep early/late adjust relative */
  2964.                             Note->Flags = eCmdSweepEarlyLateRel;
  2965.                             break;
  2966.                         case 256: /* 256 = restore duration adjust */
  2967.                             Note->Flags = eCmdRestoreDurationAdjust;
  2968.                             break;
  2969.                         case 257: /* 257 = set duration adjust */
  2970.                             Note->Flags = eCmdSetDurationAdjust;
  2971.                             break;
  2972.                         case 258: /* 258 = adjust duration adjust */
  2973.                             Note->Flags = eCmdIncDurationAdjust;
  2974.                             break;
  2975.                         case 259: /* 259 = sweep duration adjust absolute */
  2976.                             Note->Flags = eCmdSweepDurationAbs;
  2977.                             break;
  2978.                         case 260: /* 260 = sweep duration adjust relative */
  2979.                             Note->Flags = eCmdSweepDurationRel;
  2980.                             break;
  2981.                         case 261: /* 261 = set duration adjust mode */
  2982.                             Note->Flags = eCmdDurationAdjustMode;
  2983.                             break;
  2984.                         case 272: /* 272 = set meter */
  2985.                             Note->Flags = eCmdSetMeter;
  2986.                             break;
  2987.                         case 273: /* 273 = set measure number */
  2988.                             Note->Flags = eCmdSetMeasureNumber;
  2989.                             break;
  2990.                         case 288: /* 288 = comment */
  2991.                             Note->Flags = eCmdMarker;
  2992.                             break;
  2993.                         case 304: /* 304 = restore surround position */
  2994.                             Note->Flags = eCmdRestoreSurroundPosition;
  2995.                             break;
  2996.                         case 305: /* 305 = set surround position */
  2997.                             Note->Flags = eCmdSetSurroundPosition;
  2998.                             break;
  2999.                         case 306: /* 306 = adjust surround position */
  3000.                             Note->Flags = eCmdIncSurroundPosition;
  3001.                             break;
  3002.                         case 307: /* 307 = sweep surround position absolute */
  3003.                             Note->Flags = eCmdSweepSurroundAbs;
  3004.                             break;
  3005.                         case 308: /* 308 = sweep surround position relative */
  3006.                             Note->Flags = eCmdSweepSurroundRel;
  3007.                             break;
  3008.                         case 320: /* 320 = set transpose */
  3009.                             Note->Flags = eCmdSetTranspose;
  3010.                             break;
  3011.                         case 321: /* 321 = adjust transpose */
  3012.                             Note->Flags = eCmdAdjustTranspose;
  3013.                             break;
  3014.                     }
  3015.                 Note->Flags |= eCommandFlag;
  3016.             }
  3017.  
  3018.         *ObjectOut = Note;
  3019.         return eFileLoadNoError;
  3020.     }
  3021.  
  3022.  
  3023. /* write a note object to the file.  this does not handle ties since they are */
  3024. /* done separately. */
  3025. FileLoadingErrors            NoteObjectWriteDataOut(NoteObjectRec* Note,
  3026.                                                 struct BufferedOutputRec* Output)
  3027.     {
  3028.         CheckPtrExistence(Note);
  3029.         CheckPtrExistence(Output);
  3030.  
  3031.         if ((Note->Flags & eCommandFlag) == 0)
  3032.             {
  3033.                 /* note */
  3034.  
  3035.                 /*   4-byte unsigned little endian opcode field */
  3036.                 /*       for a command, the high bit will be 1 and the remaining bits will */
  3037.                 /*       be the opcode.  for a note, the high bit will be 0. */
  3038.                 if (!WriteBufferedUnsignedLongLittleEndian(Output,Note->Flags))
  3039.                     {
  3040.                         return eFileLoadDiskError;
  3041.                     }
  3042.  
  3043.                 /*   2-byte signed little endian pitch index */
  3044.                 /*       should be a value in the range 0..383.  Middle C (261.6 Hertz) = 192 */
  3045.                 if (!WriteBufferedSignedShortLittleEndian(Output,Note->a.Note.Pitch))
  3046.                     {
  3047.                         return eFileLoadDiskError;
  3048.                     }
  3049.  
  3050.                 /*   2-byte little endian small integer coded decimal portamento duration. */
  3051.                 /*       this determines how long a portamento will last, in fractions of a quarter */
  3052.                 /*       note.  it only has effect if the note is the target of a tie.  a value of */
  3053.                 /*       0 means instantaneous, i.e. no portamento. */
  3054.                 if (!WriteBufferedSignedShortLittleEndian(Output,
  3055.                     Note->a.Note.PortamentoDuration))
  3056.                     {
  3057.                         return eFileLoadDiskError;
  3058.                     }
  3059.  
  3060.                 /*   2-byte little endian small integer coded decimal early/late adjustment */
  3061.                 /*       this determines the displacement in time of the occurrence of the note */
  3062.                 /*       in frations of a quarter note. */
  3063.                 if (!WriteBufferedSignedShortLittleEndian(Output,Note->a.Note.EarlyLateAdjust))
  3064.                     {
  3065.                         return eFileLoadDiskError;
  3066.                     }
  3067.  
  3068.                 /*   2-byte little endian small integer coded decimal duration adjustment */
  3069.                 /*       this value changes the duration of the note by being added to the */
  3070.                 /*       duration or being multiplied by the duration. */
  3071.                 if (!WriteBufferedSignedShortLittleEndian(Output,Note->a.Note.DurationAdjust))
  3072.                     {
  3073.                         return eFileLoadDiskError;
  3074.                     }
  3075.  
  3076.                 /*   2-byte little endian small integer coded decimal release point 1 location */
  3077.                 /*       this determines when the release of the first sustain/loop will occur */
  3078.                 /*       in fractions of the current note's duration.  it is relative to the origin */
  3079.                 /*       as determined by the opcode field. */
  3080.                 if (!WriteBufferedSignedShortLittleEndian(Output,Note->a.Note.ReleasePoint1))
  3081.                     {
  3082.                         return eFileLoadDiskError;
  3083.                     }
  3084.  
  3085.                 /*   2-byte little endian small integer coded decimal release point 2 location */
  3086.                 /*       this determines when the release of the second sustain/loop will occur. */
  3087.                 if (!WriteBufferedSignedShortLittleEndian(Output,Note->a.Note.ReleasePoint2))
  3088.                     {
  3089.                         return eFileLoadDiskError;
  3090.                     }
  3091.  
  3092.                 /*   2-byte little endian small integer coded decimal overall loudness adjustment */
  3093.                 /*       this factor scales the total volume output of the oscillators for this */
  3094.                 /*       particular note.  It is multiplied, so a value of 1 makes no change in */
  3095.                 /*       loudness. */
  3096.                 if (!WriteBufferedSignedShortLittleEndian(Output,
  3097.                     Note->a.Note.OverallLoudnessAdjustment))
  3098.                     {
  3099.                         return eFileLoadDiskError;
  3100.                     }
  3101.  
  3102.                 /*   2-byte little endian small integer coded decimal stereo position adjustment. */
  3103.                 /*       this value adjusts where the sound will be located in stereo.  -1 is */
  3104.                 /*       the far left, 1 is the far right, and 0 is center. */
  3105.                 if (!WriteBufferedSignedShortLittleEndian(Output,
  3106.                     Note->a.Note.StereoPositionAdjustment))
  3107.                     {
  3108.                         return eFileLoadDiskError;
  3109.                     }
  3110.  
  3111.                 /*   2-byte little endian small integer coded decimal surround position adjustment. */
  3112.                 /*       this value adjusts where the sound will be located in surroud. */
  3113.                 /*       1 is front and -1 is rear */
  3114.                 if (!WriteBufferedSignedShortLittleEndian(Output,
  3115.                     Note->a.Note.SurroundPositionAdjustment))
  3116.                     {
  3117.                         return eFileLoadDiskError;
  3118.                     }
  3119.  
  3120.                 /*   2-byte little endian small integer coded decimal accent 1 value */
  3121.                 if (!WriteBufferedSignedShortLittleEndian(Output,Note->a.Note.Accent1))
  3122.                     {
  3123.                         return eFileLoadDiskError;
  3124.                     }
  3125.  
  3126.                 /*   2-byte little endian small integer coded decimal accent 2 value */
  3127.                 if (!WriteBufferedSignedShortLittleEndian(Output,Note->a.Note.Accent2))
  3128.                     {
  3129.                         return eFileLoadDiskError;
  3130.                     }
  3131.  
  3132.                 /*   2-byte little endian small integer coded decimal accent 3 value */
  3133.                 if (!WriteBufferedSignedShortLittleEndian(Output,Note->a.Note.Accent3))
  3134.                     {
  3135.                         return eFileLoadDiskError;
  3136.                     }
  3137.  
  3138.                 /*   2-byte little endian small integer coded decimal accent 4 value */
  3139.                 if (!WriteBufferedSignedShortLittleEndian(Output,Note->a.Note.Accent4))
  3140.                     {
  3141.                         return eFileLoadDiskError;
  3142.                     }
  3143.  
  3144.                 /*   2-byte little endian fake pitch value */
  3145.                 /*       this value has a range of -1..383.  If it is not -1, then it will be used */
  3146.                 /*       to determine which sample a multisampled oscillator will use.  If it is -1 */
  3147.                 /*       then the actual pitch will be used to select a sample. */
  3148.                 if (!WriteBufferedSignedShortLittleEndian(Output,
  3149.                     Note->a.Note.MultisamplePitchAsIf))
  3150.                     {
  3151.                         return eFileLoadDiskError;
  3152.                     }
  3153.  
  3154.                 /*   2-byte little endian small integer coded decimal pitch disp depth adjustment */
  3155.                 /*       this adjusts the maximum amplitude of the pitch displacement depth */
  3156.                 /*       oscillator (vibrato).  The value has units of either half steps or hertz */
  3157.                 /*       depending on the setting in the opcode word. */
  3158.                 if (!WriteBufferedSignedShortLittleEndian(Output,
  3159.                     Note->a.Note.PitchDisplacementDepthAdjustment))
  3160.                     {
  3161.                         return eFileLoadDiskError;
  3162.                     }
  3163.  
  3164.                 /*   2-byte little endian small integer coded decimal pitch displ rate adjustment */
  3165.                 /*       this adjusts the maximum amplitude of the pitch displacement rate */
  3166.                 /*       oscillator. the units are periods per second. */
  3167.                 if (!WriteBufferedSignedShortLittleEndian(Output,
  3168.                     Note->a.Note.PitchDisplacementRateAdjustment))
  3169.                     {
  3170.                         return eFileLoadDiskError;
  3171.                     }
  3172.  
  3173.                 /*   2-byte little endian small integer coded decimal pitch displ start point adjust */
  3174.                 /*       this value adjusts when the pitch displacement envelopes start.  the */
  3175.                 /*       location is from start or end of note, depending on the opcode settings, and */
  3176.                 /*       is in fractions of the current note's duration. */
  3177.                 if (!WriteBufferedSignedShortLittleEndian(Output,
  3178.                     Note->a.Note.PitchDisplacementStartPoint))
  3179.                     {
  3180.                         return eFileLoadDiskError;
  3181.                     }
  3182.  
  3183.                 /*   2-byte little endian small integer coded decimal hurry-up factor */
  3184.                 /*       this factor scales the total speed at which all envelopes change.  this is */
  3185.                 /*       multiplicative, so a value of 1 makes no change, and smaller values make */
  3186.                 /*       transitions go faster. */
  3187.                 if (!WriteBufferedSignedShortLittleEndian(Output,Note->a.Note.HurryUpFactor))
  3188.                     {
  3189.                         return eFileLoadDiskError;
  3190.                     }
  3191.  
  3192.                 /*   2-byte little endian small integer coded decimal detuning value */
  3193.                 /*       this value is added to the pitch of the note to detune.  its units are */
  3194.                 /*       either hertz or half steps depending on the opcode word. */
  3195.                 if (!WriteBufferedSignedShortLittleEndian(Output,Note->a.Note.Detuning))
  3196.                     {
  3197.                         return eFileLoadDiskError;
  3198.                     }
  3199.             }
  3200.          else
  3201.             {
  3202.                 unsigned long                Command;
  3203.  
  3204.                 /* write out a command */
  3205.  
  3206.                 /* convert internal enum index into the file format index */
  3207.                 switch (Note->Flags & ~eCommandFlag)
  3208.                     {
  3209.                         default:
  3210.                             EXECUTE(PRERR(ForceAbort,"NoteObjectWriteDataOut:  bad command"));
  3211.                             break;
  3212.                         case eCmdRestoreTempo: /* 16 = restore tempo */
  3213.                             Command = 16;
  3214.                             break;
  3215.                         case eCmdSetTempo: /* 17 = set tempo */
  3216.                             Command = 17;
  3217.                             break;
  3218.                         case eCmdIncTempo: /* 18 = adjust tempo */
  3219.                             Command = 18;
  3220.                             break;
  3221.                         case eCmdSweepTempoAbs: /* 19 = sweep tempo absolute */
  3222.                             Command = 19;
  3223.                             break;
  3224.                         case eCmdSweepTempoRel: /* 20 = sweep tempo relative */
  3225.                             Command = 20;
  3226.                             break;
  3227.                         case eCmdRestoreStereoPosition: /* 32 = restore stereo position */
  3228.                             Command = 32;
  3229.                             break;
  3230.                         case eCmdSetStereoPosition: /* 33 = set stereo position */
  3231.                             Command = 33;
  3232.                             break;
  3233.                         case eCmdIncStereoPosition: /* 34 = adjust stereo position */
  3234.                             Command = 34;
  3235.                             break;
  3236.                         case eCmdSweepStereoAbs: /* 35 = sweep stereo position absolute */
  3237.                             Command = 35;
  3238.                             break;
  3239.                         case eCmdSweepStereoRel: /* 36 = sweep stereo position relative */
  3240.                             Command = 36;
  3241.                             break;
  3242.                         case eCmdRestoreVolume: /* 48 = restore volume */
  3243.                             Command = 48;
  3244.                             break;
  3245.                         case eCmdSetVolume: /* 49 = set volume */
  3246.                             Command = 49;
  3247.                             break;
  3248.                         case eCmdIncVolume: /* 50 = adjust volume */
  3249.                             Command = 50;
  3250.                             break;
  3251.                         case eCmdSweepVolumeAbs: /* 51 = sweep volume absolute */
  3252.                             Command = 51;
  3253.                             break;
  3254.                         case eCmdSweepVolumeRel: /* 52 = sweep volume relative */
  3255.                             Command = 52;
  3256.                             break;
  3257.                         case eCmdRestoreReleasePoint1: /* 64 = restore release point 1 */
  3258.                             Command = 64;
  3259.                             break;
  3260.                         case eCmdSetReleasePoint1: /* 65 = set release point 1 */
  3261.                             Command = 65;
  3262.                             break;
  3263.                         case eCmdIncReleasePoint1: /* 66 = adjust release point 1 */
  3264.                             Command = 66;
  3265.                             break;
  3266.                         case eCmdReleasePointOrigin1: /* 67 = set release point 1 origin */
  3267.                             Command = 67;
  3268.                             break;
  3269.                         case eCmdSweepReleaseAbs1: /* 68 = sweep release point 1 absolute */
  3270.                             Command = 68;
  3271.                             break;
  3272.                         case eCmdSweepReleaseRel1: /* 69 = sweep release point 1 relative */
  3273.                             Command = 69;
  3274.                             break;
  3275.                         case eCmdRestoreReleasePoint2: /* 80 = restore release point 2 */
  3276.                             Command = 80;
  3277.                             break;
  3278.                         case eCmdSetReleasePoint2: /* 81 = set release point 2 */
  3279.                             Command = 81;
  3280.                             break;
  3281.                         case eCmdIncReleasePoint2: /* 82 = adjust release point 2 */
  3282.                             Command = 82;
  3283.                             break;
  3284.                         case eCmdReleasePointOrigin2: /* 83 = set release point 2 origin */
  3285.                             Command = 83;
  3286.                             break;
  3287.                         case eCmdSweepReleaseAbs2: /* 84 = sweep release point 2 absolute */
  3288.                             Command = 84;
  3289.                             break;
  3290.                         case eCmdSweepReleaseRel2: /* 85 = sweep release point 2 relative */
  3291.                             Command = 85;
  3292.                             break;
  3293.                         case eCmdRestoreAccent1: /* 96 = restore accent 1 */
  3294.                             Command = 96;
  3295.                             break;
  3296.                         case eCmdSetAccent1: /* 97 = set accent 1 */
  3297.                             Command = 97;
  3298.                             break;
  3299.                         case eCmdIncAccent1: /* 98 = adjust accent 1 */
  3300.                             Command = 98;
  3301.                             break;
  3302.                         case eCmdSweepAccentAbs1: /* 99 = sweep accent 1 absolute */
  3303.                             Command = 99;
  3304.                             break;
  3305.                         case eCmdSweepAccentRel1: /* 100 = sweep accent 1 relative */
  3306.                             Command = 100;
  3307.                             break;
  3308.                         case eCmdRestoreAccent2: /* 112 = restore accent 2 */
  3309.                             Command = 112;
  3310.                             break;
  3311.                         case eCmdSetAccent2: /* 113 = set accent 2 */
  3312.                             Command = 113;
  3313.                             break;
  3314.                         case eCmdIncAccent2: /* 114 = adjust accent 2 */
  3315.                             Command = 114;
  3316.                             break;
  3317.                         case eCmdSweepAccentAbs2: /* 115 = sweep accent 2 absolute */
  3318.                             Command = 115;
  3319.                             break;
  3320.                         case eCmdSweepAccentRel2: /* 116 = sweep accent 2 relative */
  3321.                             Command = 116;
  3322.                             break;
  3323.                         case eCmdRestoreAccent3: /* 128 = restore accent 3 */
  3324.                             Command = 128;
  3325.                             break;
  3326.                         case eCmdSetAccent3: /* 129 = set accent 3 */
  3327.                             Command = 129;
  3328.                             break;
  3329.                         case eCmdIncAccent3: /* 130 = adjust accent 3 */
  3330.                             Command = 130;
  3331.                             break;
  3332.                         case eCmdSweepAccentAbs3: /* 131 = sweep accent 3 absolute */
  3333.                             Command = 131;
  3334.                             break;
  3335.                         case eCmdSweepAccentRel3: /* 132 = sweep accent 3 relative */
  3336.                             Command = 132;
  3337.                             break;
  3338.                         case eCmdRestoreAccent4: /* 144 = restore accent 4 */
  3339.                             Command = 144;
  3340.                             break;
  3341.                         case eCmdSetAccent4: /* 145 = set accent 4 */
  3342.                             Command = 145;
  3343.                             break;
  3344.                         case eCmdIncAccent4: /* 146 = adjust accent 4 */
  3345.                             Command = 146;
  3346.                             break;
  3347.                         case eCmdSweepAccentAbs4: /* 147 = sweep accent 4 absolute */
  3348.                             Command = 147;
  3349.                             break;
  3350.                         case eCmdSweepAccentRel4: /* 148 = sweep accent 4 relative */
  3351.                             Command = 148;
  3352.                             break;
  3353.                         case eCmdRestorePitchDispDepth: /* 160 = restore pitch displacement depth */
  3354.                             Command = 160;
  3355.                             break;
  3356.                         case eCmdSetPitchDispDepth: /* 161 = set pitch displacement depth */
  3357.                             Command = 161;
  3358.                             break;
  3359.                         case eCmdIncPitchDispDepth: /* 162 = adjust pitch displacement depth */
  3360.                             Command = 162;
  3361.                             break;
  3362.                         case eCmdPitchDispDepthMode: /* 163 = set pitch displacement depth modulation mode */
  3363.                             Command = 163;
  3364.                             break;
  3365.                         case eCmdSweepPitchDispDepthAbs: /* 164 = sweep pitch displacement depth absolute */
  3366.                             Command = 164;
  3367.                             break;
  3368.                         case eCmdSweepPitchDispDepthRel: /* 165 = sweep pitch displacement depth relative */
  3369.                             Command = 165;
  3370.                             break;
  3371.                         case eCmdRestorePitchDispRate: /* 176 = restore pitch displacement rate */
  3372.                             Command = 176;
  3373.                             break;
  3374.                         case eCmdSetPitchDispRate: /* 177 = set pitch displacement rate */
  3375.                             Command = 177;
  3376.                             break;
  3377.                         case eCmdIncPitchDispRate: /* 178 = adjust pitch displacement rate */
  3378.                             Command = 178;
  3379.                             break;
  3380.                         case eCmdSweepPitchDispRateAbs: /* 179 = sweep pitch displacement rate absolute */
  3381.                             Command = 179;
  3382.                             break;
  3383.                         case eCmdSweepPitchDispRateRel: /* 180 = sweep pitch displacement rate relative */
  3384.                             Command = 180;
  3385.                             break;
  3386.                         case eCmdRestorePitchDispStart: /* 192 = restore pitch displacement start point */
  3387.                             Command = 192;
  3388.                             break;
  3389.                         case eCmdSetPitchDispStart: /* 193 = set pitch displacement start point */
  3390.                             Command = 193;
  3391.                             break;
  3392.                         case eCmdIncPitchDispStart: /* 194 = adjust pitch displacement start point */
  3393.                             Command = 194;
  3394.                             break;
  3395.                         case eCmdPitchDispStartOrigin: /* 195 = set pitch displacement start point origin */
  3396.                             Command = 195;
  3397.                             break;
  3398.                         case eCmdSweepPitchDispStartAbs: /* 196 = sweep pitch displacement start point absolute */
  3399.                             Command = 196;
  3400.                             break;
  3401.                         case eCmdSweepPitchDispStartRel: /* 197 = sweep pitch displacement start point relative */
  3402.                             Command = 197;
  3403.                             break;
  3404.                         case eCmdRestoreHurryUp: /* 208 = restore hurry-up factor */
  3405.                             Command = 208;
  3406.                             break;
  3407.                         case eCmdSetHurryUp: /* 209 = set hurry-up factor */
  3408.                             Command = 209;
  3409.                             break;
  3410.                         case eCmdIncHurryUp: /* 210 = adjust hurry-up factor */
  3411.                             Command = 210;
  3412.                             break;
  3413.                         case eCmdSweepHurryUpAbs: /* 211 = sweep hurry-up factor absolute */
  3414.                             Command = 211;
  3415.                             break;
  3416.                         case eCmdSweepHurryUpRel: /* 212 = sweep hurry-up factor relative */
  3417.                             Command = 212;
  3418.                             break;
  3419.                         case eCmdRestoreDetune: /* 224 = restore detuning */
  3420.                             Command = 224;
  3421.                             break;
  3422.                         case eCmdSetDetune: /* 225 = set detuning */
  3423.                             Command = 225;
  3424.                             break;
  3425.                         case eCmdIncDetune: /* 226 = adjust detuning */
  3426.                             Command = 226;
  3427.                             break;
  3428.                         case eCmdDetuneMode: /* 227 = set detuning mode */
  3429.                             Command = 227;
  3430.                             break;
  3431.                         case eCmdSweepDetuneAbs: /* 228 = sweep detuning absolute */
  3432.                             Command = 228;
  3433.                             break;
  3434.                         case eCmdSweepDetuneRel: /* 229 = sweep detuning relative */
  3435.                             Command = 229;
  3436.                             break;
  3437.                         case eCmdRestoreEarlyLateAdjust: /* 240 = restore early/late adjust */
  3438.                             Command = 240;
  3439.                             break;
  3440.                         case eCmdSetEarlyLateAdjust: /* 241 = set early/late adjust */
  3441.                             Command = 241;
  3442.                             break;
  3443.                         case eCmdIncEarlyLateAdjust: /* 242 = adjust early/late adjust */
  3444.                             Command = 242;
  3445.                             break;
  3446.                         case eCmdSweepEarlyLateAbs: /* 243 = sweep early/late adjust absolute */
  3447.                             Command = 243;
  3448.                             break;
  3449.                         case eCmdSweepEarlyLateRel: /* 244 = sweep early/late adjust relative */
  3450.                             Command = 244;
  3451.                             break;
  3452.                         case eCmdRestoreDurationAdjust: /* 256 = restore duration adjust */
  3453.                             Command = 256;
  3454.                             break;
  3455.                         case eCmdSetDurationAdjust: /* 257 = set duration adjust */
  3456.                             Command = 257;
  3457.                             break;
  3458.                         case eCmdIncDurationAdjust: /* 258 = adjust duration adjust */
  3459.                             Command = 258;
  3460.                             break;
  3461.                         case eCmdSweepDurationAbs: /* 259 = sweep duration adjust absolute */
  3462.                             Command = 259;
  3463.                             break;
  3464.                         case eCmdSweepDurationRel: /* 260 = sweep duration adjust relative */
  3465.                             Command = 260;
  3466.                             break;
  3467.                         case eCmdDurationAdjustMode: /* 261 = set duration adjust mode */
  3468.                             Command = 261;
  3469.                             break;
  3470.                         case eCmdSetMeter: /* 272 = set meter */
  3471.                             Command = 272;
  3472.                             break;
  3473.                         case eCmdSetMeasureNumber: /* 273 = set measure number */
  3474.                             Command = 273;
  3475.                             break;
  3476.                         case eCmdMarker: /* 288 = comment */
  3477.                             Command = 288;
  3478.                             break;
  3479.                         case eCmdRestoreSurroundPosition: /* 304 = restore surround position */
  3480.                             Command = 304;
  3481.                             break;
  3482.                         case eCmdSetSurroundPosition: /* 305 = set surround position */
  3483.                             Command = 305;
  3484.                             break;
  3485.                         case eCmdIncSurroundPosition: /* 306 = adjust surround position */
  3486.                             Command = 306;
  3487.                             break;
  3488.                         case eCmdSweepSurroundAbs: /* 307 = sweep surround position absolute */
  3489.                             Command = 307;
  3490.                             break;
  3491.                         case eCmdSweepSurroundRel: /* 308 = sweep surround position relative */
  3492.                             Command = 308;
  3493.                             break;
  3494.                         case eCmdSetTranspose: /* 320 = set transpose */
  3495.                             Command = 320;
  3496.                             break;
  3497.                         case eCmdAdjustTranspose: /* 321 = adjust transpose */
  3498.                             Command = 321;
  3499.                             break;
  3500.                     }
  3501.                 if (!WriteBufferedUnsignedLongLittleEndian(Output,Command | eCommandFlag))
  3502.                     {
  3503.                         return eFileLoadDiskError;
  3504.                     }
  3505.  
  3506.                 /* write out the arguments */
  3507.                 switch (Note->Flags & ~eCommandFlag)
  3508.                     {
  3509.                         default:
  3510.                             EXECUTE(PRERR(ForceAbort,"NoteObjectWriteDataOut:  bad command"));
  3511.                             break;
  3512.  
  3513.                         /*   no arguments */
  3514.                         case eCmdRestoreTempo: /* 16 = restore tempo */
  3515.                         case eCmdRestoreStereoPosition: /* 32 = restore stereo position */
  3516.                         case eCmdRestoreVolume: /* 48 = restore volume */
  3517.                         case eCmdRestoreReleasePoint1: /* 64 = restore release point 1 */
  3518.                         case eCmdRestoreReleasePoint2: /* 80 = restore release point 2 */
  3519.                         case eCmdRestoreAccent1: /* 96 = restore accent 1 */
  3520.                         case eCmdRestoreAccent2: /* 112 = restore accent 2 */
  3521.                         case eCmdRestoreAccent3: /* 128 = restore accent 3 */
  3522.                         case eCmdRestoreAccent4: /* 144 = restore accent 4 */
  3523.                         case eCmdRestorePitchDispDepth: /* 160 = restore pitch displacement depth */
  3524.                         case eCmdRestorePitchDispRate: /* 176 = restore pitch displacement rate */
  3525.                         case eCmdRestorePitchDispStart: /* 192 = restore pitch displacement start point */
  3526.                         case eCmdRestoreHurryUp: /* 208 = restore hurry-up factor */
  3527.                         case eCmdRestoreDetune: /* 224 = restore detuning */
  3528.                         case eCmdRestoreEarlyLateAdjust: /* 240 = restore early/late adjust */
  3529.                         case eCmdRestoreDurationAdjust: /* 256 = restore duration adjust */
  3530.                         case eCmdRestoreSurroundPosition: /* 304 = restore surround position */
  3531.                             break;
  3532.  
  3533.                         /*   4-byte little endian large/extended integer coded decimal */
  3534.                         case eCmdSetTempo: /* 17 = set tempo */
  3535.                         case eCmdIncTempo: /* 18 = adjust tempo */
  3536.                         case eCmdSetStereoPosition: /* 33 = set stereo position */
  3537.                         case eCmdIncStereoPosition: /* 34 = adjust stereo position */
  3538.                         case eCmdSetVolume: /* 49 = set volume */
  3539.                         case eCmdIncVolume: /* 50 = adjust volume */
  3540.                         case eCmdSetReleasePoint1: /* 65 = set release point 1 */
  3541.                         case eCmdIncReleasePoint1: /* 66 = adjust release point 1 */
  3542.                         case eCmdSetReleasePoint2: /* 81 = set release point 2 */
  3543.                         case eCmdIncReleasePoint2: /* 82 = adjust release point 2 */
  3544.                         case eCmdSetAccent1: /* 97 = set accent 1 */
  3545.                         case eCmdIncAccent1: /* 98 = adjust accent 1 */
  3546.                         case eCmdSetAccent2: /* 113 = set accent 2 */
  3547.                         case eCmdIncAccent2: /* 114 = adjust accent 2 */
  3548.                         case eCmdSetAccent3: /* 129 = set accent 3 */
  3549.                         case eCmdIncAccent3: /* 130 = adjust accent 3 */
  3550.                         case eCmdSetAccent4: /* 145 = set accent 4 */
  3551.                         case eCmdIncAccent4: /* 146 = adjust accent 4 */
  3552.                         case eCmdSetPitchDispDepth: /* 161 = set pitch displacement depth */
  3553.                         case eCmdIncPitchDispDepth: /* 162 = adjust pitch displacement depth */
  3554.                         case eCmdSetPitchDispRate: /* 177 = set pitch displacement rate */
  3555.                         case eCmdIncPitchDispRate: /* 178 = adjust pitch displacement rate */
  3556.                         case eCmdSetPitchDispStart: /* 193 = set pitch displacement start point */
  3557.                         case eCmdIncPitchDispStart: /* 194 = adjust pitch displacement start point */
  3558.                         case eCmdSetHurryUp: /* 209 = set hurry-up factor */
  3559.                         case eCmdIncHurryUp: /* 210 = adjust hurry-up factor */
  3560.                         case eCmdSetDetune: /* 225 = set detuning */
  3561.                         case eCmdIncDetune: /* 226 = adjust detuning */
  3562.                         case eCmdSetEarlyLateAdjust: /* 241 = set early/late adjust */
  3563.                         case eCmdIncEarlyLateAdjust: /* 242 = adjust early/late adjust */
  3564.                         case eCmdSetDurationAdjust: /* 257 = set duration adjust */
  3565.                         case eCmdIncDurationAdjust: /* 258 = adjust duration adjust */
  3566.                         case eCmdSetMeasureNumber: /* 273 = set measure number */
  3567.                         case eCmdSetSurroundPosition: /* 305 = set surround position */
  3568.                         case eCmdIncSurroundPosition: /* 306 = adjust surround position */
  3569.                         case eCmdSetTranspose: /* 320 = set transpose */
  3570.                         case eCmdAdjustTranspose: /* 321 = adjust transpose */
  3571.                             if (!WriteBufferedSignedLongLittleEndian(Output,Note->a.Command.Argument1))
  3572.                                 {
  3573.                                     return eFileLoadDiskError;
  3574.                                 }
  3575.                             break;
  3576.  
  3577.                         /*   4-byte little endian large/extended integer coded decimal */
  3578.                         /*   4-byte little endian large/extended integer coded decimal */
  3579.                         case eCmdSweepTempoAbs: /* 19 = sweep tempo absolute */
  3580.                         case eCmdSweepTempoRel: /* 20 = sweep tempo relative */
  3581.                         case eCmdSweepStereoAbs: /* 35 = sweep stereo position absolute */
  3582.                         case eCmdSweepStereoRel: /* 36 = sweep stereo position relative */
  3583.                         case eCmdSweepVolumeAbs: /* 51 = sweep volume absolute */
  3584.                         case eCmdSweepVolumeRel: /* 52 = sweep volume relative */
  3585.                         case eCmdSweepReleaseAbs1: /* 68 = sweep release point 1 absolute */
  3586.                         case eCmdSweepReleaseRel1: /* 69 = sweep release point 1 relative */
  3587.                         case eCmdSweepReleaseAbs2: /* 84 = sweep release point 2 absolute */
  3588.                         case eCmdSweepReleaseRel2: /* 85 = sweep release point 2 relative */
  3589.                         case eCmdSweepAccentAbs1: /* 99 = sweep accent 1 absolute */
  3590.                         case eCmdSweepAccentRel1: /* 100 = sweep accent 1 relative */
  3591.                         case eCmdSweepAccentAbs2: /* 115 = sweep accent 2 absolute */
  3592.                         case eCmdSweepAccentRel2: /* 116 = sweep accent 2 relative */
  3593.                         case eCmdSweepAccentAbs3: /* 131 = sweep accent 3 absolute */
  3594.                         case eCmdSweepAccentRel3: /* 132 = sweep accent 3 relative */
  3595.                         case eCmdSweepAccentAbs4: /* 147 = sweep accent 4 absolute */
  3596.                         case eCmdSweepAccentRel4: /* 148 = sweep accent 4 relative */
  3597.                         case eCmdSweepPitchDispDepthAbs: /* 164 = sweep pitch displacement depth absolute */
  3598.                         case eCmdSweepPitchDispDepthRel: /* 165 = sweep pitch displacement depth relative */
  3599.                         case eCmdSweepPitchDispRateAbs: /* 179 = sweep pitch displacement rate absolute */
  3600.                         case eCmdSweepPitchDispRateRel: /* 180 = sweep pitch displacement rate relative */
  3601.                         case eCmdSweepPitchDispStartAbs: /* 196 = sweep pitch displacement start point absolute */
  3602.                         case eCmdSweepPitchDispStartRel: /* 197 = sweep pitch displacement start point relative */
  3603.                         case eCmdSweepHurryUpAbs: /* 211 = sweep hurry-up factor absolute */
  3604.                         case eCmdSweepHurryUpRel: /* 212 = sweep hurry-up factor relative */
  3605.                         case eCmdSweepDetuneAbs: /* 228 = sweep detuning absolute */
  3606.                         case eCmdSweepDetuneRel: /* 229 = sweep detuning relative */
  3607.                         case eCmdSweepEarlyLateAbs: /* 243 = sweep early/late adjust absolute */
  3608.                         case eCmdSweepEarlyLateRel: /* 244 = sweep early/late adjust relative */
  3609.                         case eCmdSweepDurationAbs: /* 259 = sweep duration adjust absolute */
  3610.                         case eCmdSweepDurationRel: /* 260 = sweep duration adjust relative */
  3611.                         case eCmdSetMeter: /* 272 = set meter */
  3612.                         case eCmdSweepSurroundAbs: /* 307 = sweep surround position absolute */
  3613.                         case eCmdSweepSurroundRel: /* 308 = sweep surround position relative */
  3614.                             if (!WriteBufferedSignedLongLittleEndian(Output,Note->a.Command.Argument1))
  3615.                                 {
  3616.                                     return eFileLoadDiskError;
  3617.                                 }
  3618.                             if (!WriteBufferedSignedLongLittleEndian(Output,Note->a.Command.Argument2))
  3619.                                 {
  3620.                                     return eFileLoadDiskError;
  3621.                                 }
  3622.                             break;
  3623.  
  3624.                         /*   1-byte origin specifier */
  3625.                         /*       -1 = 0 */
  3626.                         /*       0 = 1 */
  3627.                         case eCmdReleasePointOrigin1: /* 67 = set release point 1 origin */
  3628.                         case eCmdReleasePointOrigin2: /* 83 = set release point 2 origin */
  3629.                         case eCmdPitchDispDepthMode: /* 163 = set pitch displacement depth modulation mode */
  3630.                         case eCmdPitchDispStartOrigin: /* 195 = set pitch displacement start point origin */
  3631.                         case eCmdDetuneMode: /* 227 = set detuning mode */
  3632.                         case eCmdDurationAdjustMode: /* 261 = set duration adjust mode */
  3633.                             if (!WriteBufferedUnsignedChar(Output,
  3634.                                 (Note->a.Command.Argument1 < 0) ? 0 : 1))
  3635.                                 {
  3636.                                     return eFileLoadDiskError;
  3637.                                 }
  3638.                             break;
  3639.  
  3640.                         /*   4-byte little endian length of comment text string */
  3641.                         /*   n-byte comment text string (line feed = 0x0a) */
  3642.                         case eCmdMarker: /* 288 = comment */
  3643.                             if (!WriteBufferedSignedLongLittleEndian(Output,
  3644.                                 PtrSize(Note->a.Command.StringArgument)))
  3645.                                 {
  3646.                                     return eFileLoadDiskError;
  3647.                                 }
  3648.                             if (!WriteBufferedOutput(Output,PtrSize(Note->a.Command.StringArgument),
  3649.                                 Note->a.Command.StringArgument))
  3650.                                 {
  3651.                                     return eFileLoadDiskError;
  3652.                                 }
  3653.                             break;
  3654.                     }
  3655.             }
  3656.  
  3657.         return eFileLoadNoError;
  3658.     }
  3659.  
  3660.  
  3661. /* make a complete copy of the note/command and any blocks it has allocated */
  3662. NoteObjectRec*                DeepCopyNoteObject(NoteObjectRec* Note)
  3663.     {
  3664.         NoteObjectRec*            Copy;
  3665.  
  3666.         CheckPtrExistence(Note);
  3667.  
  3668.         /* duplicate */
  3669.         Copy = (NoteObjectRec*)AllocPtrCanFail(sizeof(NoteObjectRec),"NoteObjectRec");
  3670.         if (Copy == NIL)
  3671.             {
  3672.                 return NIL;
  3673.             }
  3674.  
  3675.         /* copy data over */
  3676.         Copy->Flags = Note->Flags;
  3677.         if ((Note->Flags & eCommandFlag) != 0)
  3678.             {
  3679.                 /* command */
  3680.                 Copy->a.Command.Argument1 = Note->a.Command.Argument1;
  3681.                 Copy->a.Command.Argument2 = Note->a.Command.Argument2;
  3682.                 Copy->a.Command.Argument3 = Note->a.Command.Argument3;
  3683.                 Copy->a.Command.StringArgument = CopyPtr(Note->a.Command.StringArgument);
  3684.                 if (Copy->a.Command.StringArgument == NIL)
  3685.                     {
  3686.                         ReleasePtr((char*)Copy);
  3687.                         return NIL;
  3688.                     }
  3689.                 SetTag(Copy->a.Command.StringArgument,"NoteObjectRec: StringArgument");
  3690.             }
  3691.          else
  3692.             {
  3693.                 /* note */
  3694.                 Copy->a.Note.Pitch = Note->a.Note.Pitch;
  3695.                 Copy->a.Note.PortamentoDuration = Note->a.Note.PortamentoDuration;
  3696.                 Copy->a.Note.EarlyLateAdjust = Note->a.Note.EarlyLateAdjust;
  3697.                 Copy->a.Note.DurationAdjust = Note->a.Note.DurationAdjust;
  3698.                 Copy->a.Note.Tie = Note->a.Note.Tie;
  3699.                 Copy->a.Note.ReleasePoint1 = Note->a.Note.ReleasePoint1;
  3700.                 Copy->a.Note.ReleasePoint2 = Note->a.Note.ReleasePoint2;
  3701.                 Copy->a.Note.OverallLoudnessAdjustment = Note->a.Note.OverallLoudnessAdjustment;
  3702.                 Copy->a.Note.StereoPositionAdjustment = Note->a.Note.StereoPositionAdjustment;
  3703.                 Copy->a.Note.SurroundPositionAdjustment = Note->a.Note.SurroundPositionAdjustment;
  3704.                 Copy->a.Note.Accent1 = Note->a.Note.Accent1;
  3705.                 Copy->a.Note.Accent2 = Note->a.Note.Accent2;
  3706.                 Copy->a.Note.Accent3 = Note->a.Note.Accent3;
  3707.                 Copy->a.Note.Accent4 = Note->a.Note.Accent4;
  3708.                 Copy->a.Note.MultisamplePitchAsIf = Note->a.Note.MultisamplePitchAsIf;
  3709.                 Copy->a.Note.PitchDisplacementDepthAdjustment = Note->a.Note.PitchDisplacementDepthAdjustment;
  3710.                 Copy->a.Note.PitchDisplacementRateAdjustment = Note->a.Note.PitchDisplacementRateAdjustment;
  3711.                 Copy->a.Note.PitchDisplacementStartPoint = Note->a.Note.PitchDisplacementStartPoint;
  3712.                 Copy->a.Note.HurryUpFactor = Note->a.Note.HurryUpFactor;
  3713.                 Copy->a.Note.Detuning = Note->a.Note.Detuning;
  3714.             }
  3715.  
  3716.         return Copy;
  3717.     }
  3718.